Exemplo n.º 1
0
        public static List <string> FindValidShaderProperties(Material m, WaterfallMaterialPropertyType propType)
        {
            List <string> validProps = new List <string>();

            foreach (KeyValuePair <string, MaterialData> mProp in ShaderLoader.GetShaderPropertyMap())
            {
                if (m.HasProperty(mProp.Key))
                {
                    if (mProp.Value.type == propType)
                    {
                        validProps.Add(mProp.Key);
                    }
                }
            }
            return(validProps);
        }
Exemplo n.º 2
0
        protected void InitializeShaderProperties(Material m)
        {
            colorValues          = new Dictionary <string, Color>();
            floatValues          = new Dictionary <string, float>();
            textureValues        = new Dictionary <string, string>();
            textureScaleValues   = new Dictionary <string, Vector2>();
            textureOffsetValues  = new Dictionary <string, Vector2>();
            colorStrings         = new Dictionary <string, string[]>();
            floatStrings         = new Dictionary <string, string>();
            textureOffsetStrings = new Dictionary <string, string[]>();
            textureScaleStrings  = new Dictionary <string, string[]>();
            colorTextures        = new Dictionary <string, Texture2D>();

            foreach (KeyValuePair <string, MaterialData> mProp in ShaderLoader.GetShaderPropertyMap())
            {
                if (m.HasProperty(mProp.Key))
                {
                    if (mProp.Value.type == WaterfallMaterialPropertyType.Color)
                    {
                        colorValues.Add(mProp.Key, m.GetColor(mProp.Key));
                        colorStrings.Add(mProp.Key, MaterialUtils.ColorToStringArray(m.GetColor(mProp.Key)));
                        colorTextures.Add(mProp.Key, MaterialUtils.GenerateColorTexture(64, 32, m.GetColor(mProp.Key)));
                    }
                    if (mProp.Value.type == WaterfallMaterialPropertyType.Float)
                    {
                        floatValues.Add(mProp.Key, m.GetFloat(mProp.Key));
                        floatStrings.Add(mProp.Key, m.GetFloat(mProp.Key).ToString());
                    }
                    if (mProp.Value.type == WaterfallMaterialPropertyType.Texture)
                    {
                        textureValues.Add(mProp.Key, m.GetTexture(mProp.Key).name);
                        textureScaleValues.Add(mProp.Key, m.GetTextureScale(mProp.Key));
                        textureOffsetValues.Add(mProp.Key, m.GetTextureOffset(mProp.Key));
                        textureOffsetStrings.Add(mProp.Key, new string[] { $"{m.GetTextureOffset(mProp.Key).x}", $"{m.GetTextureOffset(mProp.Key).y}" });
                        textureScaleStrings.Add(mProp.Key, new string[] { $"{m.GetTextureScale(mProp.Key).x}", $"{m.GetTextureScale(mProp.Key).y}" });
                    }
                }
            }
        }