Just wondering if there is a way to run IConvertGameObjectToEntity.Convert() before GameObjectConversionSystem.OnUpdate()
Bump
Don’t really get the question. You can create and manually call GameObjectConversionSystem.Update() if you need it to happen earlier.
Otherwise you can use
GameObjectConversionUtility.ConvertScene()
GameObjectConversionUtility.ConvertGameObjectHierarchy()
I don’t get the question either. There’s multiple GameObjectConversionSystem systems that run, with one of them being the one that calls the IConvertGameObjectToEntity. You can create your own systems too and even convert Unity components into custom entities if you want.
ok let me try and explain.
I have a subScene with a gameObject containing some a data on a MonoBehaviour implementing IConvertGameObjectToEntity. Let call it buildData.
I also have a GameObjectConversionSystem that required buildData but when I press “Rebuild Entities Cache” the GameObjectConversionSystem executes before IConvertGameObjectToEntity.
Or is there a better way of doing this
OK if I understood correctly Im going to write a GameObjectConversionSystem for my gameObject , setUp the dependancies and use subScenes to cache as a bonus. Here is my 1st attempt at a manual GameObjectConversionSystem. Let me know if this is GarBo code
//[UpdateAfter(typeof(XXXXXXXX))]
public class HexSphereCovertToEntities : GameObjectConversionSystem
{
protected override void OnUpdate()
{
GameObject go = GameObject.FindGameObjectWithTag("tagHexSphereBuildGameObject");
HexSphereBuildDataLiveLink data = go.GetComponent<HexSphereBuildDataLiveLink>();
WORLD_SIZE worldSize = data.worldSize;
int subdivisionsCount = data.subdivisionsCount;
int raduis = data.raduis;
int hexesCount = data.hexesCount;
int triangleCount = data.triangleCount;
Entity e = GetPrimaryEntity(go);
EntityQuery eqBuildDataComp = this.DstEntityManager.CreateEntityQuery(ComponentType.ReadOnly<HexSphereBuildDataComponent>());
if (this.DstEntityManager.HasComponent<HexSphereBuildDataComponent>(e))
{
Entities.With(eqBuildDataComp).ForEach<HexSphereBuildDataComponent>((ref HexSphereBuildDataComponent d) =>
{
d.worldSize = worldSize;
d.subdivisionsCount = subdivisionsCount;
d.raduis = raduis;
d.hexesCount = hexesCount;
d.triangleCount = triangleCount;
});
}
else
{
var hexSphereBuildSettingsData = new HexSphereBuildDataComponent
{
worldSize = worldSize,
subdivisionsCount = subdivisionsCount,
raduis = raduis,
hexesCount = hexesCount,
triangleCount = triangleCount
};
this.DstEntityManager.AddComponentData(e, hexSphereBuildSettingsData);
}
}
}