コード例 #1
0
ファイル: HybridUtils.cs プロジェクト: bsymon/ECS-Match3
        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
            });
        }
コード例 #2
0
        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);
        }