예제 #1
0
        public GameObjectSurrogate(GameObject go)
        {
            this.name = go.name;

            components = new List <ComponentSurrogate>();

            Component[] realComponents = go.GetComponents <Component>();
            foreach (Component item in realComponents)
            {
                System.Type type = item.GetType();

                if (type == typeof(Transform))
                {
                    TransformSurrogate transformSurrogate = new TransformSurrogate(item as Transform);
                    components.Add(transformSurrogate);
                }
                else if (type == typeof(MeshFilter))
                {
                    MeshFilterSurrogate meshFilterSurrogate = new MeshFilterSurrogate(item as MeshFilter);
                    components.Add(meshFilterSurrogate);
                }
                else if (type == typeof(MeshRenderer))
                {
                    MeshRendererSurrogate meshRendererSurrogate = new MeshRendererSurrogate(item as MeshRenderer);
                    components.Add(meshRendererSurrogate);
                }
                else if (type == typeof(Terrain))
                {
                    Debug.Log("Found Terrain");
                    TerrainSurrogate terrainSurrogate = new TerrainSurrogate(item as Terrain);
                    components.Add(terrainSurrogate);
                }
            }

            List <GameObject> realChildren = new List <GameObject>();

            foreach (Transform child in go.GetComponentsInChildren <Transform>())
            {
                if (child.gameObject == go)
                {
                    continue;
                }
                if (child.parent != go.transform)
                {
                    continue;
                }
                else
                {
                    realChildren.Add(child.gameObject);
                }
            }

            children = new List <GameObjectSurrogate>();
            foreach (GameObject realChild in realChildren)
            {
                GameObjectSurrogate childSurrogate = new GameObjectSurrogate(realChild);
                children.Add(childSurrogate);
            }
        }
예제 #2
0
        public SceneSurrogate(Scene scene)
        {
            this.name = scene.name;

            rootGameObjects = new List <GameObjectSurrogate>();
            foreach (GameObject go in scene.GetRootGameObjects())
            {
                GameObjectSurrogate goSurrogate = new GameObjectSurrogate(go);
                rootGameObjects.Add(goSurrogate);
            }
        }