Beispiel #1
0
        public static void ReplaceShader(UnityParser parser, string path)
        {
            Shader s = Shader.Import(path);

            if (s.m_Script.Length > 0)
            {
                for (int i = 0; i < parser.Cabinet.Components.Count; i++)
                {
                    Component asset = parser.Cabinet.Components[i];
                    if (asset.classID1 == UnityClassID.Shader)
                    {
                        Shader sic = parser.Cabinet.LoadComponent(asset.pathID);
                        if (sic.m_Name == s.m_Name)
                        {
                            sic.m_Script = s.m_Script;
                            return;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void ReplaceShader(string path)
        {
            Shader sh = Shader.Import(path);

            if (sh.m_Script.Length > 0)
            {
                for (int i = 0; i < Parser.Cabinet.Components.Count; i++)
                {
                    Component asset = Parser.Cabinet.Components[i];
                    if (asset.classID1 == UnityClassID.Shader)
                    {
                        Shader shader = null;
                        string name;
                        if (asset is NotLoaded)
                        {
                            name = ((NotLoaded)asset).Name;
                            if (name != sh.m_Name)
                            {
                                continue;
                            }
                            shader = Parser.Cabinet.LoadComponent(asset.pathID);
                        }
                        else
                        {
                            shader = (Shader)asset;
                            name   = shader.m_Name;
                        }
                        if (name == sh.m_Name)
                        {
                            shader.m_Script = sh.m_Script;
                            Changed         = true;
                            return;
                        }
                    }
                }
            }
        }