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.