Beispiel #1
0
        public void DrawFog(Fog fog, string hash)
        {
            bool fogModeDefault = fog.mode == FogMode.Default;
            bool hideFog        = !MaterialBuffer.options["ShowDefault"] && (fog.IsDefault() || fogModeDefault);

            if (!hideFog)
            {
                MaterialBuffer.options[hash + "Fog"] = EditorGUILayout.Foldout(MaterialBuffer.options[hash + "Fog"], "Fog");
                if (MaterialBuffer.options[hash + "Fog"])
                {
                    ++EditorGUI.indentLevel;
                    fog.mode = (FogMode)this.Draw("Mode", fog.mode);
                    if (!fogModeDefault)
                    {
                        fog.color   = (Color)this.Draw("Color", fog.color, Color.white);
                        fog.density = (float)this.Draw("Density", fog.density, 0.0f);
                        fog.range   = (Vector2)this.Draw("Range", fog.range, Vector2.zero);
                    }
                    --EditorGUI.indentLevel;
                }
            }
        }
Beispiel #2
0
        public string GenerateCommon(Common common, string pad)
        {
            StringBuilder output = new StringBuilder();

            if (!common.IsCommonDefault())
            {
                if (common.cull != Cull.Default)
                {
                    output.AppendLine(pad + "Cull " + common.cull);
                }
                if (common.zTest != Test.Default)
                {
                    output.AppendLine(pad + "ZTest " + common.zTest);
                }
                if (common.zWrite != Toggle.Default)
                {
                    output.AppendLine(pad + "ZWrite " + common.zWrite);
                }
                if (common.alphaTest != Test.Default)
                {
                    string compare = " [" + common.alphaCutoff + "]";
                    if (common.alphaCutoff.IsNumber())
                    {
                        compare = compare.Remove("[", "]");
                    }
                    if (common.alphaTest == Test.Off || common.alphaTest == Test.Always)
                    {
                        compare = "";
                    }
                    output.AppendLine(pad + "AlphaTest " + common.alphaTest + compare);
                }
                this.SortPreset(common);
                if (common.blendPreset != BlendPreset.Default)
                {
                    string extra = "";
                    if (common.blendPreset == BlendPreset.CustomExtended)
                    {
                        extra = ", " + common.blendAlpha[0] + " " + common.blendAlpha[1];
                    }
                    if (common.blendPreset == BlendPreset.Off)
                    {
                        output.AppendLine(pad + "Blend Off");
                    }
                    else
                    {
                        output.AppendLine(pad + "Blend " + common.blend[0] + " " + common.blend[1] + extra);
                        if (common.blendOp != BlendOp.Default)
                        {
                            output.AppendLine(pad + "BlendOp " + common.blendOp);
                        }
                    }
                }
                if (common.offset != Vector2.zero)
                {
                    output.AppendLine(pad + "Offset " + common.offset.ToString().Pack());
                }
                if (!common.fog.IsDefault() && common.fog.mode != FogMode.Default)
                {
                    Fog    fog      = common.fog;
                    string fogColor = fog.color.ToString().Remove("RGBA", " ");
                    string fogRange = fog.range.ToString().Pack();
                    output.AppendLine(pad + "Fog{");
                    output.AppendLine(pad + "\tMode " + fog.mode);
                    output.AppendLine(pad + "\tColor " + fogColor);
                    if (fog.density != 0)
                    {
                        output.AppendLine(pad + "\tDensity " + fog.density);
                    }
                    if (fog.range != Vector2.zero)
                    {
                        output.AppendLine(pad + "\tRange " + fogRange);
                    }
                    output.AppendLine(pad + "}");
                }
            }
            return(output.ToString().Remove(".000", ".0"));
        }