Esempio n. 1
0
        protected void InitializeShaderProperties(Material m)
        {
            colorValues         = new Dictionary <string, Color>();
            floatValues         = new Dictionary <string, float>();
            textureValues       = new Dictionary <string, string>();
            textureEdits        = new Dictionary <string, bool>();
            textureScaleValues  = new Dictionary <string, Vector2>();
            textureOffsetValues = new Dictionary <string, Vector2>();
            vec4Values          = new Dictionary <string, Vector4>();

            colorStrings         = new Dictionary <string, string[]>();
            colorEdits           = new Dictionary <string, bool>();
            floatStrings         = new Dictionary <string, string>();
            textureOffsetStrings = new Dictionary <string, string[]>();
            textureScaleStrings  = new Dictionary <string, string[]>();
            vec4Strings          = new Dictionary <string, string[]>();
            colorTextures        = new Dictionary <string, Texture2D>();

            foreach (KeyValuePair <string, MaterialData> mProp in WaterfallConstants.ShaderPropertyMap)
            {
                if (m.HasProperty(mProp.Key))
                {
                    if (mProp.Value.type == WaterfallMaterialPropertyType.Color)
                    {
                        colorValues.Add(mProp.Key, m.GetColor(mProp.Key));
                        colorEdits.Add(mProp.Key, false);
                        colorStrings.Add(mProp.Key, MaterialUtils.ColorToStringArray(m.GetColor(mProp.Key)));
                        colorTextures.Add(mProp.Key, MaterialUtils.GenerateColorTexture(32, 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.Vector4)
                    {
                        Vector4 vec4 = m.GetVector(mProp.Key);

                        vec4Values.Add(mProp.Key, vec4);
                        vec4Strings.Add(mProp.Key, new string[] { $"{vec4.x}", $"{vec4.y}", $"{vec4.z}", $"{vec4.w}" });
                    }
                    if (mProp.Value.type == WaterfallMaterialPropertyType.Texture)
                    {
                        textureValues.Add(mProp.Key, m.GetTexture(mProp.Key).name);
                        textureEdits.Add(mProp.Key, false);
                        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}" });
                    }
                }
            }
        }
        private void GetLightValues()
        {
            intensityValue  = light.intensity;
            intensityString = light.intensity.ToString();

            rangeString = light.range.ToString();
            rangeValue  = light.range;

            angleString = light.angle.ToString();
            angleValue  = light.angle;

            colorValue   = light.color;
            colorString  = MaterialUtils.ColorToStringArray(colorValue);
            colorTexture = TextureUtils.GenerateColorTexture(32, 32, colorValue);

            if (light.lightType == LightType.Point)
            {
                typeFlag = 1;
            }
            else
            {
                typeFlag = 0;
            }
        }