Пример #1
0
        private static bool _ClearMat(Material mat, string path)
        {
            shaderValue.Clear();
            Shader shader = mat.shader;
            int    count  = ShaderUtil.GetPropertyCount(shader);

            for (int i = 0; i < count; ++i)
            {
                ShaderValue sv   = null;
                string      name = ShaderUtil.GetPropertyName(shader, i);
                ShaderUtil.ShaderPropertyType type = ShaderUtil.GetPropertyType(shader, i);
                switch (type)
                {
                case ShaderUtil.ShaderPropertyType.Color:
                    sv = new ShaderColorValue(name, type, mat);
                    break;

                case ShaderUtil.ShaderPropertyType.Vector:
                    sv = new ShaderVectorValue(name, type, mat);
                    break;

                case ShaderUtil.ShaderPropertyType.Float:
                    sv = new ShaderFloatValue(name, type, mat);
                    break;

                case ShaderUtil.ShaderPropertyType.Range:
                    sv = new ShaderFloatValue(name, type, mat);
                    break;

                case ShaderUtil.ShaderPropertyType.TexEnv:
                    sv = new ShaderTexValue(name, type, mat);
                    break;
                }
                shaderValue.Add(sv);
            }
            Material emptyMat = new Material(shader);

            mat.CopyPropertiesFromMaterial(emptyMat);
            UnityEngine.Object.DestroyImmediate(emptyMat);
            for (int i = 0; i < shaderValue.Count; ++i)
            {
                ShaderValue sv = shaderValue[i];
                sv.SetValue(mat);
            }
            mat.renderQueue = -1;
            return(true);
        }
Пример #2
0
            public static void GetShaderValue(Material mat, List <ShaderValue> shaderValueLst)
            {
                Shader shader = mat.shader;
                int    count  = ShaderUtil.GetPropertyCount(shader);

                for (int i = 0; i < count; ++i)
                {
                    ShaderValue sv   = null;
                    string      name = ShaderUtil.GetPropertyName(shader, i);
                    ShaderUtil.ShaderPropertyType type = ShaderUtil.GetPropertyType(shader, i);
                    switch (type)
                    {
                    case ShaderUtil.ShaderPropertyType.Color:
                        sv = new ShaderColorValue(name, type, mat);
                        break;

                    case ShaderUtil.ShaderPropertyType.Vector:
                        sv = new ShaderVectorValue(name, type, mat);
                        break;

                    case ShaderUtil.ShaderPropertyType.Float:
                        sv = new ShaderFloatValue(name, type, mat);
                        break;

                    case ShaderUtil.ShaderPropertyType.Range:
                        sv = new ShaderFloatValue(name, type, mat);
                        break;

                    case ShaderUtil.ShaderPropertyType.TexEnv:
                        sv = new ShaderTexValue(name, type, mat);
                        break;
                    }
                    shaderValueLst.Add(sv);
                }
                ShaderKeyWordValue keyword = new ShaderKeyWordValue(mat);

                shaderValueLst.Add(keyword);
            }