I’ve read runtime conversion is removed in ECS 1.0 after working so well for us for several years. Hybrid rendering has been renamed Entities.Graphics which includes component and API name changes etc.
At runtime, we select from a number of prefabs and convert them to Entities at runtime. We’ve read that runtime conversion is “almost never necessary”. However, we cannot find any way round runtime generation. We’re probably overlooking something.
Here is a snippet of one of our runtime conversion scenarios.
public Transform[] obstaclePrefabs;
public int obstacles = 2500;
public World asteroidWorld;
public List<EntityArchetype> asteriodEntityArchetypeList;
public List<Entity> asteriodPrefabEntityList;
public AsteroidSystem asteroidSystem;
private BlobAssetStore blobAssetStore;
// Cutdown simplified version
public void Initialise()
{
int numObstaclePrefabs = obstaclePrefabs == null ? 0 : obstaclePrefabs.Length;
blobAssetStore = new BlobAssetStore();
GameObjectConversionSettings conversionSettings = GameObjectConversionSettings.FromWorld(asteroidWorld, blobAssetStore);
for (int pfIdx = 0; pfIdx < numObstaclePrefabs; pfIdx++)
{
//..
Entity prefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(obstaclePrefabs[pfIdx].gameObject, asteroidWorld);
asteriodPrefabEntityList.Add(prefabEntity);
ComponentType[] archetypeComponentTypeArray = new ComponentType[4];
archetypeComponentTypeArray[0] = typeof(Translation);
archetypeComponentTypeArray[1] = typeof(Rotation);
archetypeComponentTypeArray[2] = typeof(Asteroid);
// NOTE: Requires hybrid renderer
archetypeComponentTypeArray[3] = typeof(RenderMesh);
EntityArchetype entityArcheType = asteroidWorld.EntityManager.CreateArchetype(archetypeComponentTypeArray);
asteriodEntityArchetypeList.Add(entityArcheType);
}
//...
asteroidSystem = asteroidWorld.GetOrCreateSystem<AsteroidSystem>();
}
What options are available to replace runtime prefab conversion? So far, I’ve not been able to find any coding examples that demonstrate how we could do this.
We don’t use subscenes.
At runtime we have a mixture of gameobjects with regular monobehaviours and entities in our scenes.