Esempio n. 1
0
        public static ShaderProps GetPropsForSupportedShader(string shaderName)
        {
            if (m_shaderPropMap == null)
            {
                m_shaderPropMap = new Dictionary <string, ShaderProps>();
                foreach (var prop in typeof(PreShaderPropExporter).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    if (prop.GetCustomAttributes(typeof(PreExportShaderAttribute), true).Any())
                    {
                        var kv = (KeyValuePair <string, ShaderProps>)prop.GetValue(null, null);
                        m_shaderPropMap.Add(kv.Key, kv.Value);
                    }
                }
            }

            ShaderProps props;

            if (m_shaderPropMap.TryGetValue(shaderName, out props))
            {
                return(props);
            }

#if UNITY_EDITOR
            // fallback
            Debug.LogWarningFormat("{0} is not predefined shader. Use ShaderUtil", shaderName);
            var shader = Shader.Find(shaderName);
            return(ShaderProps.FromShader(shader));
#else
            return(null);
#endif
        }
Esempio n. 2
0
        static void PreExport(SupportedShader supportedShader)
        {
            var path = GetExportDir(supportedShader.TargetFolder).Child(EscapeShaderName(supportedShader.ShaderName) + ".cs");

            Debug.LogFormat("PreExport: {0}", path.FullPath);

            var shader = Shader.Find(supportedShader.ShaderName);
            var props  = ShaderProps.FromShader(shader, supportedShader.NormalMapProps);

            File.WriteAllText(path.FullPath, props.ToString(shader.name));
        }