public static ConvertedGameObject ConvertGameObjectHierarchy(GameObjectEntity gameObject, World dstEntityWorld) { var entityManager = dstEntityWorld.EntityManager; gameObject.ObjectRenderer.enabled = false; // foreach(var component in gameObject.IgnoredComponents) // component.enabled = false; var prefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(gameObject.gameObject, dstEntityWorld); entityManager.SetName(prefabEntity, gameObject.gameObject.name); entityManager.AddComponentObject(prefabEntity, gameObject); gameObject.LinkedEntity = prefabEntity; gameObject.ObjectRenderer.enabled = true; // foreach(var component in gameObject.IgnoredComponents) // component.enabled = true; return(new ConvertedGameObject() { entity = prefabEntity, gameObject = gameObject }); }
public static Entity Instantiate(this EntityManager entityManager, GameObjectEntity gameObject) { var instance = GameObject.Instantiate(gameObject); instance.ObjectRenderer.enabled = false; var entity = GameObjectConversionUtility.ConvertGameObjectHierarchy(instance.gameObject, entityManager.World); instance.LinkedEntity = entity; foreach (var component in instance.ComponentsToLink) { entityManager.AddComponentObject(entity, component); } entityManager.SetName(entity, instance.gameObject.name); entityManager.AddComponentObject(entity, instance.transform); entityManager.AddComponentObject(entity, instance); instance.ObjectRenderer.enabled = true; return(entity); }