public static void ClearMat(Material mat) { shaderValue.Clear(); ShaderValue.GetShaderValue(mat, shaderValue); Material emptyMat = new Material(mat.shader); mat.CopyPropertiesFromMaterial(emptyMat); UnityEngine.Object.DestroyImmediate(emptyMat); for (int i = 0; i < shaderValue.Count; ++i) { ShaderValue sv = shaderValue[i]; sv.SetValue(mat); } }
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); }