예제 #1
0
        public static void ConvertAndInjectOriginal(GameObject root)
        {
            using (var gameObjectWorld = new GameObjectConversionSettings(World.Active, GameObjectConversionUtility.ConversionFlags.AssignName).CreateConversionWorld())
            {
                GameObjectEntity.AddToEntityManager(gameObjectWorld.EntityManager, root);

                GameObjectConversionUtility.Convert(gameObjectWorld);

                var entity = GameObjectConversionUtility.GameObjectToConvertedEntity(gameObjectWorld, root);
                InjectOriginalComponents(World.Active.EntityManager, entity, root.transform);
            }
        }
예제 #2
0
        public static void ConvertAndInjectOriginal(GameObject root)
        {
            var gameObjectWorld = GameObjectConversionUtility.CreateConversionWorld(World.Active, default(Hash128), 0);

            GameObjectEntity.AddToEntityManager(gameObjectWorld.EntityManager, root);

            GameObjectConversionUtility.Convert(gameObjectWorld, World.Active);

            var entity = GameObjectConversionUtility.GameObjectToConvertedEntity(gameObjectWorld, root);

            InjectOriginalComponents(World.Active.EntityManager, entity, root.transform);

            gameObjectWorld.Dispose();
        }
예제 #3
0
        public static void ConvertAndInjectOriginal(GameObject root, World convertToWorld)
        {
            var gameObjectWorld = (World)createConversionWorld.Invoke(null, new object[] { convertToWorld, default(Hash128), GameObjectConversionUtility.ConversionFlags.AssignName });

            GameObjectEntity.AddToEntityManager(gameObjectWorld.EntityManager, root);

            convert.Invoke(null, new object[] { gameObjectWorld, convertToWorld });

            var entity = (Entity)gameObjectToConvertedEntity.Invoke(null, new object[] { gameObjectWorld, root });

            injectOriginalComponents.Invoke(null, new object[] { convertToWorld.EntityManager, entity, root.transform });

            gameObjectWorld.Dispose();
        }
예제 #4
0
        public static void AddRecurse(EntityManager manager, Transform transform)
        {
            GameObjectEntity.AddToEntityManager(manager, transform.gameObject);

            var convert = transform.GetComponent <ConvertToEntity>();

            if (convert != null && convert.ConversionMode == Mode.ConvertAndInjectGameObject)
            {
                return;
            }

            foreach (Transform child in transform)
            {
                AddRecurse(manager, child);
            }
        }
        static void AddRecurse(EntityManager manager, Transform transform, HashSet <Transform> toBeDetached, List <Transform> toBeInjected)
        {
            if (transform.GetComponent <StopConvertToEntity>() != null)
            {
                toBeDetached.Add(transform);
                return;
            }

            GameObjectEntity.AddToEntityManager(manager, transform.gameObject);

            if (IsConvertAndInject(transform.gameObject))
            {
                toBeDetached.Add(transform);
                toBeInjected.Add(transform);
            }
            else
            {
                foreach (Transform child in transform)
                {
                    AddRecurse(manager, child, toBeDetached, toBeInjected);
                }
            }
        }