Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entitas 0.47.8 incompatible with ScriptableObject #564

Closed
roygear opened this issue Jan 18, 2018 · 9 comments
Closed

Entitas 0.47.8 incompatible with ScriptableObject #564

roygear opened this issue Jan 18, 2018 · 9 comments

Comments

@roygear
Copy link
Contributor

roygear commented Jan 18, 2018

tested in Window 7, unity 2017.3

If project contain a ScriptableObject class like this:

using UnityEngine;
[Game]
public class Configs : ScriptableObject
{
    public GameObject gameObject;
}

below error will appear after execute Jenny gen

Sequence contains no elements

and generator won't work

@chiuan
Copy link

chiuan commented Jan 18, 2018

why are you need to do this ???

@roygear
Copy link
Contributor Author

roygear commented Jan 18, 2018

@chiuan you can make global setting on Unity's inspector. This important to Game designer

@ghost
Copy link

ghost commented Jan 18, 2018

What do you think about:

[Game]
public class ConfigsComponent : IComponent
{
    public Configs value;
}
public Configs : ScriptableObject {
<....>
}
public class LoadConfigsInitializeSystem : IInitializeSystem {
    private readonly Configs configs;
    private readonly GameContext context;
    public LoadConfigsInitializeSystem(GameContext context, Configs configs) {
        this.configs = configs;
        this.context = context;
    }
    public void Initialize() {
        context.CreateEntity().AddConfigs(configs);
    }
}

Just write a simple InitializeSystem to set your Component.

@KumoKairo
Copy link
Contributor

This thing actually worked back in the day, we used to store settings components like that. Just mark a custom Settings : ScriptableObject class with [Game] and it should generate an appropriate component:

SettingsComponent : IComponent
{
    Settings value;
}

So I guess it's an issue with the new generator?

@AVAVT
Copy link

AVAVT commented Jan 18, 2018

It took some time to separate Component and ScriptableObject, but it looks cleaner now so I have no complaint. Entitas' Attribute above non-IComponent looks confusing.

@sschmid
Copy link
Owner

sschmid commented Jan 18, 2018

Can reproduce, works with the default code generator, doesn't work with roslyn. Will investigate...

@sschmid
Copy link
Owner

sschmid commented Jan 18, 2018

As a workaround please manually create the ConfigsComponent

[Game]
public sealed class ConfigsComponent : Entitas.IComponent {
    public Configs value;
}

@sschmid
Copy link
Owner

sschmid commented Jan 18, 2018

Ok, fixed. Will be in next release.

In case anyone is interested: Explanation:
The fix for #532 introduced that behaviour because all inherited members where inspected too to support subclassed components. The same functionality was applied for non-components. I fixed this to not inspect sublasses of non-components.

@sschmid
Copy link
Owner

sschmid commented Jan 18, 2018

Fixed in Entitas 0.47.9

@sschmid sschmid closed this as completed Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

5 participants