public void Add(GameObject go)
        {
            // containers
            VisitToCreateMesh_r(go);
            VisitToCreateMaterial_r(go);
            VisitToCreateTexture(containerTable.GetEnumerable <MaterialContainer>());

            // game object
            VisitToCreateGameObjectNode_r(go);

            // nodes - for component
            VisitToCreateNode_r <Camera, CameraNode>(go);
            VisitToCreateNode_r <Light, LightNode>(go);
            VisitToCreateRenderNode_r(go);
            VisitToCreateScriptNode_r(go);

            // script variable에서 참조하는 객체

            foreach (var node in graphNodeTable.GetEnumerable <ScriptNode>())
            {
                foreach (var val in node.VariableEnumerable)
                {
                    Material mtl = val.GetMaterial();
                    if (mtl && !containerTable.Contains <MaterialContainer>(mtl.GetInstanceID()))
                    {
                        var c = new MaterialContainer(mtl);
                        containerTable.Add(c.InstanceId, c);
                    }

                    Texture tex = val.GetTexture();
                    if (tex && !containerTable.Contains <TextureContainer>(tex.GetInstanceID()))
                    {
                        var c = new TextureContainer(tex);
                        containerTable.Add(c.InstanceId, c);
                    }
                }
            }
            // 새로운 material이 추가되면 연관된 texture가 생겼을지 모른다
            VisitToCreateTexture(containerTable.GetEnumerable <MaterialContainer>());
        }
Ejemplo n.º 2
0
        void VisitToCreateNode_r <Comp, Node>(GameObject go)
            where Comp : Component
            where Node : class, IUnityNode, new()
        {
            var comp = go.GetComponent <Comp>();

            var isValid = true;

            if (typeof(Comp) == typeof(Light) && comp != null)
            {
                // remove if light is mixed or realtime
                // baked light is not need in scene
                // https://github.com/MattRix/UnityDecompiled/blob/master/UnityEditor/UnityEditor/LightEditor.cs
                // tested on unity 5.4.0f3
                var light            = (Light)(object)comp;
                var serializedObject = new SerializedObject(light);
                var lightmapping     = serializedObject.FindProperty("m_Lightmapping");
                int lightmappingMode = lightmapping.intValue;
                if (lightmappingMode == (int)LightmappingMode.Baked)
                {
                    isValid = false;
                }
            }

            if (comp && isValid)
            {
                var node = new Node();
                node.Initialize(comp, containerTable);

                if (!graphNodeTable.Contains <Node>(node.InstanceId))
                {
                    graphNodeTable.Add(node.InstanceId, node);
                }
            }

            for (int i = 0; i < go.transform.childCount; i++)
            {
                VisitToCreateNode_r <Comp, Node>(go.transform.GetChild(i).gameObject);
            }
        }
        void VisitToCreateNode_r <Comp, Node>(GameObject go)
            where Comp : Component
            where Node : class, IUnityNode, new()
        {
            var comp = go.GetComponent <Comp>();

            if (comp)
            {
                var node = new Node();
                node.Initialize(comp, containerTable);

                if (!graphNodeTable.Contains <Node>(node.InstanceId))
                {
                    graphNodeTable.Add(node.InstanceId, node);
                }
            }

            for (int i = 0; i < go.transform.childCount; i++)
            {
                VisitToCreateNode_r <Comp, Node>(go.transform.GetChild(i).gameObject);
            }
        }