convert empty GameObject to entity

I would like to get into DOTS and started with a simple setup. I just want to have a Level component holding the current level and increasing it with a LevelUpSystem. So my component is

public struct LevelComponent : IComponentData
{
    public float Value;
}

For the system I tried to use the job system and burst compiler

public class LevelUpSystem : JobComponentSystem
{
    [BurstCompile]
    struct LevelUpJob : IJobForEach<LevelComponent>
    {
        public void Execute(ref LevelComponent level)
        {
            level.Value++;
        }
    }

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        LevelUpJob job = new LevelUpJob();
        return job.Schedule(this, inputDeps);
    }
}

Due to the fact I don’t have entities I created an empty GameObject and want to convert it to an entity. I attached the following script to it

public class LevelBehaviour : MonoBehaviour, IConvertGameObjectToEntity
{
    [SerializeField]
    private float initialLevel;

    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        dstManager.AddComponentData(entity, new LevelComponent { Value = initialLevel });
    }
}

and set the initial level value to 3. When running the game there is no entity listed up in the Entity Debugger. Did I miss something?

I tried to add this setup to a minimalistic repository for reproduction

https://github.com/matthiashermsen/dots-playground/tree/master/Assets/Scripts

It would be awesome if someone could tell me what might be missing or wrong.

You need to attach ConvertToEntity component to the gameobject or put it in a subscene.

This might change in the next entities package update.

@BanJaxe ah thank you very much. Did I understand correctly (from your link) that I should always prefer creating a subscene for that GameObject? Because it’s way more easy to just attach that ConvertToEntity script :slight_smile:

And by the way … Is it already planned when the package will be out from the preview? It feels like everything changes from week to week :hushed:

Yes it does changes often, as DOTS is officially not for production ready.

On Unity it was told that DOTS will go out of preview around the release of unity 2010.1

True, I recall that message too.

And even then, DOTS packages don’t stop evolve. So is expected there will be 1.0.1, 1.1.3. etc.