Me again playing around with SubScenes & LiveLinkConvertGameView have a few more questions.
I wrote this very simple system as an exercise to try understand this whole concept and how it relates to what I want to do.
namespace Learn.Something
{
//
//IComponentData
struct EntityCountComponent : IComponentData
{
public int entityCount;
}
struct EntityDataComponent : IComponentData
{
public int entityData;
}
//
// GameObjectConversionSystem
public class ConversionSystem : GameObjectConversionSystem
{
protected override void OnUpdate()
{
this.Entities.ForEach((TestProxy data) =>
{
Debug.Log("<b> <size=13> <color=#DE67DA>Info : 1 ConversionSystem : Converting Entities.</color> </size> </b>");
var ePrimary = this.GetPrimaryEntity(data);
var cData = new EntityCountComponent
{
entityCount = data.numEntities
};
this.DstEntityManager.AddComponentData(ePrimary, cData);
});
}
}
//
// ComponentSystem
public class CreateSystem : ComponentSystem
{
private EntityQuery qEntityCount;
private EntityQuery qEntityData;
private EntityArchetype aEntityData;
protected override void OnCreate()
{
aEntityData = EntityManager.CreateArchetype
(
ComponentType.ReadOnly<EntityDataComponent>()
);
qEntityData = GetEntityQuery
(
typeof(EntityDataComponent)
);
qEntityCount = GetEntityQuery
(
ComponentType.ReadOnly<EntityCountComponent>()
);
qEntityCount.SetFilterChanged(typeof(EntityCountComponent));
}
protected override void OnUpdate()
{
Entities.With(qEntityCount).ForEach((ref EntityCountComponent c) =>
{
Debug.Log("<b> <size=13> <color=#67A9DE>Info : 2 CreateSystem : Create Entities.</color> </size> </b>");
EntityManager.DestroyEntity(qEntityData); // NOT VERY HAPPY WHERE THIS IS SITTING
NativeArray<Entity> e = new NativeArray<Entity>(c.entityCount, Allocator.TempJob);
EntityManager.CreateEntity(aEntityData, e);
e.Dispose();
});
}
}
//
// JobComponentSystem
[UpdateAfter(typeof(CreateSystem))]
public class UpdateSystem : JobComponentSystem
{
private EntityQuery qEntityData;
protected override void OnCreate()
{
qEntityData = GetEntityQuery
(
typeof(EntityDataComponent)
);
qEntityData.SetFilterChanged(typeof(EntityDataComponent));
}
[BurstCompile]
struct SetData : IJobForEachWithEntity<EntityDataComponent>
{
public void Execute(Entity entity, int index, ref EntityDataComponent c)
{
DebugInfo();
c.entityData = index;
}
[BurstDiscard]
private void DebugInfo()
{
Debug.Log("<b> <size=13> <color=#9DF155>Info : 3 SetDataSystem : Setting Data .</color> </size> </b>");
}
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
inputDeps = new SetData
{
}.Schedule(qEntityData, inputDeps);
return inputDeps;
}
}
}
Ok now looking at this video I you see my actions ( this gets a bit crazy but I need to understand this )
-
In edit mode I open the subscene and I see the pink debug print for the GameObjectConversionSystem.- makes sense
-
I edit my game object and I see the same thing - makes sense
-
I save the subscene and I see the GameObjectConversionSystem execute twice - Why is that ?
-
I enter play mode and the CreateSystem executes (dubug print blue) followed by the UpdateSystem printing a debug log for each entity in green - makes sense
5)I press edit on the sub scene at runtime and both the GameObjectConversionSystem & CreateSystem executes - Kind of make sense but would like some more info.
-
I change my gameObj field numEntities and once again the GameObjectConversionSystem & CreateSystem executes - makes sense … but no UpdateSystem execution - Why is this ?
-
At this point I can never get the UpdateSystem to execute, doesnt matter what I do - Why is this ?
Thanks in advance for entertaining my OCD.