Entitas-csharp: Entitas 0.47.8 incompatible with ScriptableObject

Created on 18 Jan 2018  路  9Comments  路  Source: sschmid/Entitas-CSharp

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

Most helpful comment

Fixed in Entitas 0.47.9

All 9 comments

why are you need to do this ???

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

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.

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?

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.

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

As a workaround please manually create the ConfigsComponent

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

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.

Fixed in Entitas 0.47.9

Was this page helpful?
0 / 5 - 0 ratings

Related issues

angelotadres picture angelotadres  路  5Comments

KumoKairo picture KumoKairo  路  3Comments

yuchting picture yuchting  路  4Comments

sschmid picture sschmid  路  4Comments

moixxsyc picture moixxsyc  路  4Comments