예제 #1
0
 // 绘制自定义样式属性
 public virtual void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     editor.DefaultShaderProperty(prop, label.text);
 }
예제 #2
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        _debugMode                = FindProperty("_DebugMode", properties);
        _outlineWidthMode         = FindProperty("_OutlineWidthMode", properties);
        _outlineColorMode         = FindProperty("_OutlineColorMode", properties);
        _blendMode                = FindProperty("_BlendMode", properties);
        _cullMode                 = FindProperty("_CullMode", properties);
        _outlineCullMode          = FindProperty("_OutlineCullMode", properties);
        _cutoff                   = FindProperty("_Cutoff", properties);
        _color                    = FindProperty("_Color", properties);
        _shadeColor               = FindProperty("_ShadeColor", properties);
        _mainTex                  = FindProperty("_MainTex", properties);
        _shadeTexture             = FindProperty("_ShadeTexture", properties);
        _bumpScale                = FindProperty("_BumpScale", properties);
        _bumpMap                  = FindProperty("_BumpMap", properties);
        _receiveShadowRate        = FindProperty("_ReceiveShadowRate", properties);
        _receiveShadowTexture     = FindProperty("_ReceiveShadowTexture", properties);
        _shadeShift               = FindProperty("_ShadeShift", properties);
        _shadeToony               = FindProperty("_ShadeToony", properties);
        _lightColorAttenuation    = FindProperty("_LightColorAttenuation", properties);
        _sphereAdd                = FindProperty("_SphereAdd", properties);
        _emissionColor            = FindProperty("_EmissionColor", properties);
        _emissionMap              = FindProperty("_EmissionMap", properties);
        _outlineWidthTexture      = FindProperty("_OutlineWidthTexture", properties);
        _outlineWidth             = FindProperty("_OutlineWidth", properties);
        _outlineScaledMaxDistance = FindProperty("_OutlineScaledMaxDistance", properties);
        _outlineColor             = FindProperty("_OutlineColor", properties);
        _outlineLightingMix       = FindProperty("_OutlineLightingMix", properties);
        _isFirstSetup             = FindProperty("_IsFirstSetup", properties);

        var uvMappedTextureProperties = new[]
        {
            _mainTex,
            _shadeTexture,
            _bumpMap,
            _receiveShadowTexture,
            _emissionMap,
            _outlineWidthTexture
        };

        foreach (var obj in materialEditor.targets)
        {
            var mat          = (Material)obj;
            var isFirstSetup = mat.GetFloat(_isFirstSetup.name);
            if (isFirstSetup < 0.5f)
            {
                continue;
            }

            mat.SetFloat(_isFirstSetup.name, 0.0f);
            var mainTex  = mat.GetTexture(_mainTex.name);
            var shadeTex = mat.GetTexture(_shadeTexture.name);
            if (mainTex != null && shadeTex == null)
            {
                mat.SetTexture(_shadeTexture.name, mainTex);
            }
        }

        foreach (var obj in materialEditor.targets)
        {
            var mat = (Material)obj;
            SetupBlendMode(mat, (RenderMode)mat.GetFloat(_blendMode.name), setRenderQueueAsDefault: false);
            SetupNormalMode(mat, mat.GetTexture(_bumpMap.name));
            SetupOutlineMode(mat,
                             (OutlineWidthMode)mat.GetFloat(_outlineWidthMode.name),
                             (OutlineColorMode)mat.GetFloat(_outlineColorMode.name));
            SetupDebugMode(mat, (DebugMode)mat.GetFloat(_debugMode.name));
            SetupCullMode(mat, (CullMode)mat.GetFloat(_cullMode.name));
        }


        EditorGUI.BeginChangeCheck();
        {
            EditorGUILayout.LabelField("Basic", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.LabelField("Mode", EditorStyles.boldLabel);
                var bm = (RenderMode)_blendMode.floatValue;
                if (PopupEnum <RenderMode>("Rendering Type", _blendMode, materialEditor))
                {
                    bm = (RenderMode)_blendMode.floatValue;
                    foreach (var obj in materialEditor.targets)
                    {
                        SetupBlendMode((Material)obj, bm, setRenderQueueAsDefault: true);
                    }
                }

                EditorGUI.showMixedValue = false;

                if (PopupEnum <CullMode>("Cull Mode", _cullMode, materialEditor))
                {
                    var cm = (CullMode)_cullMode.floatValue;
                    foreach (var obj in materialEditor.targets)
                    {
                        SetupCullMode((Material)obj, cm);
                    }
                }

                EditorGUI.showMixedValue = false;
                EditorGUILayout.Space();

                if (bm != RenderMode.Opaque)
                {
                    EditorGUILayout.LabelField("Alpha", EditorStyles.boldLabel);
                    {
                        if (bm == RenderMode.Transparent)
                        {
                            EditorGUILayout.TextField("Ensure your lit color and texture have alpha channels.");
                        }

                        if (bm == RenderMode.Cutout)
                        {
                            EditorGUILayout.TextField("Ensure your lit color and texture have alpha channels.");
                            materialEditor.ShaderProperty(_cutoff, "Cutoff");
                        }
                    }
                    EditorGUILayout.Space();
                }

                EditorGUILayout.LabelField("Color", EditorStyles.boldLabel);
                {
                    // Color
                    materialEditor.TexturePropertySingleLine(new GUIContent("Lit & Alpha", "Lit (RGB), Alpha (A)"),
                                                             _mainTex, _color);
                    materialEditor.TexturePropertySingleLine(new GUIContent("Shade", "Shade (RGB)"), _shadeTexture,
                                                             _shadeColor);
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Lighting", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.LabelField("Shade", EditorStyles.boldLabel);
                {
                    // Shade
                    materialEditor.ShaderProperty(_shadeShift, "Shift");
                    materialEditor.ShaderProperty(_shadeToony, "Toony");
                    materialEditor.ShaderProperty(_lightColorAttenuation, "LightColor Attenuation");
                }
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Shadow", EditorStyles.boldLabel);
                {
                    // Shadow
                    if (((Material)materialEditor.target).GetFloat("_ShadeShift") < 0f)
                    {
                        EditorGUILayout.LabelField(
                            "Receive rate should be lower value when Shade Shift is lower than 0.",
                            EditorStyles.wordWrappedLabel);
                    }

                    materialEditor.TexturePropertySingleLine(
                        new GUIContent("Receive Rate", "Receive Shadow Rate Map (A)"),
                        _receiveShadowTexture, _receiveShadowRate);
                }
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("MatCap", EditorStyles.boldLabel);
                {
                    // MatCap Light
                    materialEditor.TexturePropertySingleLine(new GUIContent("Additive", "Additive MatCap Texture (RGB)"),
                                                             _sphereAdd);
                }
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Emission", EditorStyles.boldLabel);
                {
                    materialEditor.TexturePropertySingleLine(new GUIContent("Emission", "Emission (RGB)"), _emissionMap,
                                                             _emissionColor);
                }
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Normal", EditorStyles.boldLabel);
                {
                    // Normal
                    EditorGUI.BeginChangeCheck();
                    materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map", "Normal Map (RGB)"), _bumpMap,
                                                             _bumpScale);
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("BumpEnabledDisabled");

                        foreach (var obj in materialEditor.targets)
                        {
                            var mat = (Material)obj;
                            SetupNormalMode(mat, mat.GetTexture(_bumpMap.name));
                        }
                    }
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Outline", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.LabelField("Width", EditorStyles.boldLabel);
                {
                    // Outline
                    EditorGUI.BeginChangeCheck();

                    PopupEnum <OutlineWidthMode>("Mode", _outlineWidthMode, materialEditor);
                    var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue;
                    if (widthMode != OutlineWidthMode.None)
                    {
                        materialEditor.TexturePropertySingleLine(
                            new GUIContent("Width", "Outline Width Texture (RGB)"),
                            _outlineWidthTexture, _outlineWidth);
                    }

                    if (widthMode == OutlineWidthMode.ScreenCoordinates)
                    {
                        materialEditor.ShaderProperty(_outlineScaledMaxDistance, "Width Scaled Max Distance");
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        var colorMode = (OutlineColorMode)_outlineColorMode.floatValue;
                        foreach (var obj in materialEditor.targets)
                        {
                            SetupOutlineMode((Material)obj, widthMode, colorMode);
                        }
                    }
                }
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Color", EditorStyles.boldLabel);
                {
                    var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue;
                    if (widthMode != OutlineWidthMode.None)
                    {
                        EditorGUI.BeginChangeCheck();

                        PopupEnum <OutlineColorMode>("Mode", _outlineColorMode, materialEditor);
                        var colorMode = (OutlineColorMode)_outlineColorMode.floatValue;

                        materialEditor.ShaderProperty(_outlineColor, "Color");
                        if (colorMode == OutlineColorMode.MixedLighting)
                        {
                            materialEditor.DefaultShaderProperty(_outlineLightingMix, "Lighting Mix");
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            foreach (var obj in materialEditor.targets)
                            {
                                SetupOutlineMode((Material)obj, widthMode, colorMode);
                            }
                        }
                    }
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Options", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.LabelField("Texture Options", EditorStyles.boldLabel);
                {
                    EditorGUI.BeginChangeCheck();
                    materialEditor.TextureScaleOffsetProperty(_mainTex);
                    if (EditorGUI.EndChangeCheck())
                    {
                        foreach (var textureProperty in uvMappedTextureProperties)
                        {
                            textureProperty.textureScaleAndOffset = _mainTex.textureScaleAndOffset;
                        }
                    }
                }
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Debugging Options", EditorStyles.boldLabel);
                {
                    if (PopupEnum <DebugMode>("Visualize", _debugMode, materialEditor))
                    {
                        var mode = (DebugMode)_debugMode.floatValue;
                        foreach (var obj in materialEditor.targets)
                        {
                            SetupDebugMode((Material)obj, mode);
                        }
                    }
                }
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel);
                {
                #if UNITY_5_6_OR_NEWER
//                    materialEditor.EnableInstancingField();
                    materialEditor.DoubleSidedGIField();
                #endif
                    materialEditor.RenderQueueField();
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
        }
        EditorGUI.EndChangeCheck();
    }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
    {
        //Debug.Log("OnGUI: " + label + " RTP_MaterialProp");

        if (!parsed)
        {
            parsed      = true;
            parsedLabel = RTP_MatPropStringParser.Parse(label);
        }
        label = parsedLabel;

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag && (show_for_active_layer == -1 || customEditor.active_layer == show_for_active_layer) && prop.name != "dummy_end")
            {
                EditorGUI.BeginDisabledGroup(customEditor.inactiveFlag);

                switch (prop.type)
                {
                //case MaterialProperty.PropType.Range: // float ranges
                //    {
                //        editor.RangeProperty(position, prop, label);
                //        break;
                //    }
                //case MaterialProperty.PropType.Float: // floats
                //    {
                //        editor.FloatProperty(position, prop, label);
                //        break;
                //    }
                case MaterialProperty.PropType.Color:     // colors
                {
                    EditorGUIUtility.labelWidth -= 30;
                    if (noAlphaFlag)
                    {
#if !UNITY_2018_1_OR_NEWER
                        prop.colorValue = EditorGUI.ColorField(position, new GUIContent(label, ""), prop.colorValue, true, false, false, null);
#else
                        prop.colorValue = EditorGUI.ColorField(position, new GUIContent(label, ""), prop.colorValue, true, false, false);
#endif
                    }
                    else
                    {
                        editor.ColorProperty(position, prop, label);
                    }
                    break;
                }

                case MaterialProperty.PropType.Texture:     // textures
                {
                    EditorGUI.BeginChangeCheck();
                    if (miniThumbFlag)
                    {
                        editor.TexturePropertyMiniThumbnail(position, prop, label, "");
                    }
                    else
                    {
                        editor.TextureProperty(position, prop, label, !noTileOffsetFlag);
                    }
                    if (EditorGUI.EndChangeCheck() && prop.textureValue != null && sharedTextures != null)
                    {
                        for (int j = 0; j < sharedTextures.Length; j++)
                        {
                            foreach (Material mat in editor.targets)
                            {
                                if (mat.HasProperty(sharedTextures[j]))
                                {
                                    mat.SetTexture(sharedTextures[j], prop.textureValue);
                                }
                            }
                        }
                    }
                    break;
                }

                case MaterialProperty.PropType.Vector:     // vectors
                {
                    if (byLayerFlag)
                    {
                        //
                        // affect single vector component depending on active layer
                        //
                        int   layerNum = customEditor.active_layer;
                        float pval     = prop.vectorValue[layerNum];
                        float nval;
                        if (minVal == maxVal)
                        {
                            // float
                            EditorGUIUtility.labelWidth -= 23;
                            nval = EditorGUI.FloatField(position, label, pval);
                        }
                        else
                        {
                            // slider
                            EditorGUIUtility.labelWidth = 160;
                            nval = EditorGUI.Slider(position, label, pval, minVal, maxVal);
                        }
                        if (pval != nval)
                        {
                            for (int i = 0; i < prop.targets.Length; i++)
                            {
                                Material mat = (prop.targets[i] as Material);
                                Vector4  vec = mat.GetVector(prop.name);
                                vec[layerNum] = nval;
                                mat.SetVector(prop.name, vec);
                            }
                        }
                    }
                    else
                    {
                        position.x     += 12;
                        position.width -= 12;
                        editor.VectorProperty(position, prop, label);
                    }
                    break;
                }

                default:
                {
                    if (customEditor.nextLabelWidth > 0)
                    {
                        EditorGUIUtility.labelWidth = customEditor.nextLabelWidth;
                        customEditor.nextLabelWidth = 0;
                    }
                    else
                    {
                        EditorGUIUtility.labelWidth -= 30;
                    }
                    editor.DefaultShaderProperty(position, prop, label);
                    break;
                }
                }

                EditorGUI.EndDisabledGroup();
            }
        }
    }
    override public void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        // get the current keywords from the material
        Material targetMat = materialEditor.target as Material;

        string[] keyWords = targetMat.shaderKeywords;

        foreach (string key in keyWords)
        {
            marcos[key] = true;
        }

        // render the shader properties using the default GUI
        foreach (var prop in properties)
        {
            if (prop.displayName.StartsWith("@"))
            {
                continue;
            }

            string[] wordbase    = prop.displayName.Split('#');
            string   label       = wordbase[0];
            string   description = "";
            if (wordbase.Length > 1)
            {
                description = wordbase[1];
            }

            string keyword = "";
            if (wordbase.Length > 2)
            {
                keyword = wordbase[2];
            }
            if (keyword != "")
            {
                if (!keyWords.Contains(keyword))
                {
                    continue;
                }
            }

            switch (prop.type)
            {
            case MaterialProperty.PropType.Float:
            {
                if (prop.name.StartsWith("#Toggle#"))
                {
                    string[] words = prop.name.Split('#');

                    var rect = EditorGUILayout.GetControlRect();
                    //EditorGUI.DrawRect(rect, new Color(0.0f, 0.0f, 0.0f, 0.5f));
                    if (!marcos.ContainsKey(words[2]))
                    {
                        marcos[words[2]] = false;
                    }
                    marcos[words[2]] = EditorGUI.Toggle(rect, label, marcos[words[2]]);
                }
                else if (prop.name.StartsWith("#Group#"))
                {
                    DrawTitleBar(label, 10, true, new Color(0.1f, 0.7f, 0.9f));
                }
                else
                {
                    DrawNameLine(label, description, 20);
                    materialEditor.FloatProperty(GetIndentRect(), prop, "");
                }
            }

            break;

            case MaterialProperty.PropType.Color:
            {
                DrawNameLine(label, description, 20);
                materialEditor.ColorProperty(GetIndentRect(), prop, "");
            }
            break;

            case MaterialProperty.PropType.Range:
                DrawNameLine(label, description, 20);
                materialEditor.RangeProperty(GetIndentRect(), prop, "");
                break;

            case MaterialProperty.PropType.Vector:
                DrawNameLine(label, description, 20, 20);
                materialEditor.VectorProperty(GetIndentRect(), prop, "");
                GUILayout.Space(20);
                break;

            case MaterialProperty.PropType.Texture:
                DrawNameLine(label, description, 20, 50);
                //materialEditor.TexturePropertySingleLine(new GUIContent(), prop);
                materialEditor.TextureProperty(GetIndentRectTex(), prop, "", true);
                GUILayout.Space(50);


                break;

            default:
                materialEditor.DefaultShaderProperty(prop, label);
                break;
            }
        }

        var newkeywords = new List <string> {
        };

        foreach (var item in marcos)
        {
            if (item.Value)
            {
                newkeywords.Add(item.Key);
            }
        }

        var newkeywordarray = newkeywords.ToArray();

        if (!(keyWords.Length == newkeywordarray.Length && keyWords.Intersect(newkeywordarray).Count() == keyWords.Length))
        {
            targetMat.shaderKeywords = newkeywords.ToArray();
            EditorUtility.SetDirty(targetMat);
        }
    }
예제 #5
0
 protected virtual void OnGUISafe(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
     editor.DefaultShaderProperty(position, prop, label);
 }
예제 #6
0
        private void Draw(MaterialEditor materialEditor, Material[] materials,
                          MaterialProperty[] uvMappedTextureProperties)
        {
            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.LabelField("Rendering", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    EditorGUILayout.LabelField("Mode", EditorStyles.boldLabel);
                    if (PopupEnum <RenderMode>("Rendering Type", _blendMode, materialEditor))
                    {
                        ModeChanged(materials, isBlendModeChangedByUser: true);
                    }

                    if (PopupEnum <CullMode>("Cull Mode", _cullMode, materialEditor))
                    {
                        ModeChanged(materials);
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Color", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    EditorGUILayout.LabelField("Texture", EditorStyles.boldLabel);
                    {
                        materialEditor.TexturePropertySingleLine(new GUIContent("Lit Color, Alpha", "Lit (RGB), Alpha (A)"),
                                                                 _mainTex, _color);

                        materialEditor.TexturePropertySingleLine(new GUIContent("Shade Color", "Shade (RGB)"), _shadeTexture,
                                                                 _shadeColor);
                    }
                    var bm = (RenderMode)_blendMode.floatValue;
                    if (bm == RenderMode.Cutout)
                    {
                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Alpha", EditorStyles.boldLabel);
                        {
                            materialEditor.ShaderProperty(_cutoff, "Cutoff");
                        }
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Lighting", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    EditorGUILayout.LabelField("Lit & Shade Mixing", EditorStyles.boldLabel);
                    {
                        materialEditor.ShaderProperty(_shadeShift,
                                                      new GUIContent("Shading Shift",
                                                                     "Zero is Default. Negative value increase lit area. Positive value increase shade area."));
                        materialEditor.ShaderProperty(_shadeToony,
                                                      new GUIContent("Shading Toony",
                                                                     "0.0 is Lambert. Higher value get toony shading."));
                        materialEditor.TexturePropertySingleLine(
                            new GUIContent("Shadow Receive Multiplier",
                                           "Texture (A) * Rate. White is Default. Black attenuates shadows."),
                            _receiveShadowTexture,
                            _receiveShadowRate);
                        materialEditor.TexturePropertySingleLine(
                            new GUIContent("Lit & Shade Mixing Multiplier",
                                           "Texture (R) * Rate. Compatible with UTS2 ShadingGradeMap. White is Default. Black amplifies shade."),
                            _shadingGradeTexture,
                            _shadingGradeRate);
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.LabelField("Light Color", EditorStyles.boldLabel);
                    {
                        materialEditor.ShaderProperty(_lightColorAttenuation, "LightColor Attenuation");
                        materialEditor.ShaderProperty(_indirectLightIntensity, "GI Intensity");
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.LabelField("Emission", EditorStyles.boldLabel);
                    {
                        materialEditor.TexturePropertySingleLine(new GUIContent("Emission", "Emission (RGB)"),
                                                                 _emissionMap,
                                                                 _emissionColor);
                        materialEditor.TexturePropertySingleLine(new GUIContent("MatCap", "MatCap Texture (RGB)"),
                                                                 _sphereAdd);
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.LabelField("Normal", EditorStyles.boldLabel);
                    {
                        // Normal
                        EditorGUI.BeginChangeCheck();
                        materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map", "Normal Map (RGB)"),
                                                                 _bumpMap,
                                                                 _bumpScale);
                        if (EditorGUI.EndChangeCheck())
                        {
                            materialEditor.RegisterPropertyChangeUndo("BumpEnabledDisabled");
                            ModeChanged(materials);
                        }
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Outline", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    // Outline
                    EditorGUILayout.LabelField("Width", EditorStyles.boldLabel);
                    {
                        if (PopupEnum <OutlineWidthMode>("Mode", _outlineWidthMode, materialEditor))
                        {
                            ModeChanged(materials);
                        }

                        var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue;
                        if (widthMode != OutlineWidthMode.None)
                        {
                            materialEditor.TexturePropertySingleLine(
                                new GUIContent("Width", "Outline Width Texture (RGB)"),
                                _outlineWidthTexture, _outlineWidth);

                            materialEditor.ShaderProperty(_outlineUseSoftNormal, "Use Soft Normal");
                        }

                        if (widthMode == OutlineWidthMode.ScreenCoordinates ||
                            widthMode == OutlineWidthMode.ScreenCoordinatesVertexColor)
                        {
                            materialEditor.ShaderProperty(_outlineScaledMaxDistance, "Width Scaled Max Distance");
                        }
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.LabelField("Color", EditorStyles.boldLabel);
                    {
                        var widthMode = (OutlineWidthMode)_outlineWidthMode.floatValue;
                        if (widthMode != OutlineWidthMode.None)
                        {
                            EditorGUI.BeginChangeCheck();

                            if (PopupEnum <OutlineColorMode>("Mode", _outlineColorMode, materialEditor))
                            {
                                ModeChanged(materials);
                            }

                            var colorMode = (OutlineColorMode)_outlineColorMode.floatValue;

                            materialEditor.ShaderProperty(_outlineColor, "Color");
                            if (colorMode == OutlineColorMode.MixedLighting)
                            {
                                materialEditor.DefaultShaderProperty(_outlineLightingMix, "Lighting Mix");
                            }
                        }
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Options", EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    EditorGUILayout.LabelField("Texture Options", EditorStyles.boldLabel);
                    {
                        EditorGUI.BeginChangeCheck();
                        materialEditor.TextureScaleOffsetProperty(_mainTex);
                        if (EditorGUI.EndChangeCheck())
                        {
                            foreach (var textureProperty in uvMappedTextureProperties)
                            {
                                textureProperty.textureScaleAndOffset = _mainTex.textureScaleAndOffset;
                            }
                        }
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.LabelField("Debugging Options", EditorStyles.boldLabel);
                    {
                        if (PopupEnum <DebugMode>("Visualize", _debugMode, materialEditor))
                        {
                            ModeChanged(materials);
                        }
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel);
                    {
#if UNITY_5_6_OR_NEWER
//                    materialEditor.EnableInstancingField();
                        materialEditor.DoubleSidedGIField();
#endif
                        materialEditor.RenderQueueField();
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();
            }
            EditorGUI.EndChangeCheck();
        }
예제 #7
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        FindProperties(properties);
        m_MaterialEditor            = materialEditor;
        EditorGUIUtility.labelWidth = 150;
        EditorGUI.BeginChangeCheck();

        EditorGUILayout.LabelField("Main Texture", EditorStyles.boldLabel);
        EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), HeaderSeparatorColor);
        GUILayout.Space(8);

        using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
        {
            GUILayout.Space(4);
            m_MaterialEditor.ColorProperty(color, color.displayName);
            m_MaterialEditor.TexturePropertySingleLine(mainTexName, mainTex);
            m_MaterialEditor.TexturePropertySingleLine(metalRoughName, metalRough);
            m_MaterialEditor.TexturePropertySingleLine(ambientOccluName, ambientOcclu);
            m_MaterialEditor.TexturePropertySingleLine(normalMapName, normalMap);
            m_MaterialEditor.TextureScaleOffsetProperty(mainTex);
        }
        GUILayout.Space(8);

        EditorGUILayout.LabelField("Accumulation Texture", EditorStyles.boldLabel);
        EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), HeaderSeparatorColor);
        GUILayout.Space(8);

        using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
        {
            GUILayout.Space(4);
            m_MaterialEditor.ColorProperty(snowColor, snowColor.displayName);
            m_MaterialEditor.TexturePropertySingleLine(snowTexName, snowTex);
            m_MaterialEditor.TexturePropertySingleLine(snowMetalRoughName, snowMetalRough);
            m_MaterialEditor.TexturePropertySingleLine(snowNormalName, snowNormal);
            m_MaterialEditor.TextureScaleOffsetProperty(snowTex);
        }
        GUILayout.Space(8);

        EditorGUILayout.LabelField("Blend Settings", EditorStyles.boldLabel);
        EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), HeaderSeparatorColor);
        GUILayout.Space(8);

        using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
        {
            m_MaterialEditor.VectorProperty(upVector, upVector.displayName);
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Up", EditorStyles.miniButtonLeft))
                {
                    upVector.vectorValue = Vector3.up;
                }
                ;
                if (GUILayout.Button("Down", EditorStyles.miniButtonMid))
                {
                    upVector.vectorValue = Vector3.down;
                }
                ;
                if (GUILayout.Button("Left", EditorStyles.miniButtonMid))
                {
                    upVector.vectorValue = Vector3.left;
                }
                ;
                if (GUILayout.Button("Right", EditorStyles.miniButtonMid))
                {
                    upVector.vectorValue = Vector3.right;
                }
                ;
                if (GUILayout.Button("Forward", EditorStyles.miniButtonMid))
                {
                    upVector.vectorValue = Vector3.forward;
                }
                ;
                if (GUILayout.Button("Backward", EditorStyles.miniButtonRight))
                {
                    upVector.vectorValue = Vector3.back;
                }
                ;
                GUILayout.FlexibleSpace();
            }
            m_MaterialEditor.RangeProperty(tolerance, tolerance.displayName);
            m_MaterialEditor.RangeProperty(softness, softness.displayName);

            Material targetMat = materialEditor.target as Material;
            bool     useVertex = Array.IndexOf(targetMat.shaderKeywords, "DO_DISPLACE") != -1;
            bool     useAOMask = Array.IndexOf(targetMat.shaderKeywords, "AO_MASK") != -1;

            useAOMask = EditorGUILayout.Toggle(useAOasMaskName, useAOMask);
            if (useAOMask)
            {
                m_MaterialEditor.DefaultShaderProperty(AOContribution, AOContribution.displayName);
            }
            useVertex = EditorGUILayout.Toggle(useVertexBlendingName, useVertex);

            if (useVertex)
            {
                m_MaterialEditor.FloatProperty(displaceAmount, displaceAmount.displayName);
            }

            if (EditorGUI.EndChangeCheck())
            {
                if (useAOMask)
                {
                    targetMat.EnableKeyword("AO_MASK");
                }
                else
                {
                    targetMat.DisableKeyword("AO_MASK");
                }

                if (useVertex)
                {
                    targetMat.EnableKeyword("DO_DISPLACE");
                }
                else
                {
                    targetMat.DisableKeyword("DO_DISPLACE");
                }
            }
        }

        EditorGUILayout.LabelField("Unity Properties", EditorStyles.boldLabel);
        EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), HeaderSeparatorColor);
        GUILayout.Space(8);

        using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
        {
            m_MaterialEditor.DoubleSidedGIField();
            m_MaterialEditor.EnableInstancingField();
        }

        GUILayout.Space(8);
        EditorGUIUtility.labelWidth = 0;
    }
예제 #8
0
    //-------------------------------------------------------------------------
    private void CoverGUI()
    {
        Header("Cover options:");
        Toggle(ref PW_Cover_Toggle, "enabled");

        if (PW_Cover_Toggle)
        {
            EditorGUILayout.LabelField(" ");
            EditorGUILayout.LabelField("Layer 0:");
            EditorGUI.indentLevel++;

            materialEditor.TexturePropertySingleLine(new GUIContent("Texture", "Cover Texture (A) Dissolve"), coverLayer0Image, coverLayer0Color);
            materialEditor.TexturePropertySingleLine(new GUIContent("Normal", ""), coverLayer0Normal, coverLayer0NormalScale);
            materialEditor.DefaultShaderProperty(coverLayer0Progress, "Progress");
            materialEditor.ShaderProperty(coverLayer0Edge, new GUIContent("Edge", "Smooth Edge of dissolve"));
            materialEditor.ShaderProperty(coverLayer0Tiling, new GUIContent("Tiling", "How many times texture repeats across Terrain"));
            materialEditor.DefaultShaderProperty(coverLayer0Wrap, "Wrap");
            materialEditor.DefaultShaderProperty(coverLayer0AlphaClamp, "Alpha Mod");
            materialEditor.DefaultShaderProperty(coverLayer0Metallic, "Metallic");
            materialEditor.DefaultShaderProperty(coverLayer0Smoothness, "Smoothness");
            materialEditor.DefaultShaderProperty(coverLayer0FadeStart, "Fade Start");
            materialEditor.DefaultShaderProperty(coverLayer0FadeDist, "Fade Distance");
            EditorGUI.indentLevel--;

            EditorGUILayout.LabelField(" ");
            EditorGUILayout.LabelField("Layer 1:");
            EditorGUI.indentLevel++;

            materialEditor.TexturePropertySingleLine(new GUIContent("Texture", "Cover Texture (A) Dissolve"), coverLayer1Image, coverLayer1Color);
            materialEditor.TexturePropertySingleLine(new GUIContent("Normal", ""), coverLayer1Normal, coverLayer1NormalScale);
            materialEditor.DefaultShaderProperty(coverLayer1Progress, "Progress");
            materialEditor.ShaderProperty(coverLayer1Edge, new GUIContent("Edge", "Smooth Edge of dissolve"));
            materialEditor.ShaderProperty(coverLayer1Tiling, new GUIContent("Tiling", "How many times texture repeats across Terrain"));
            materialEditor.DefaultShaderProperty(coverLayer1Wrap, "Wrap");
            materialEditor.DefaultShaderProperty(coverLayer1AlphaClamp, "Alpha Mod");
            materialEditor.DefaultShaderProperty(coverLayer1Metallic, "Metallic");
            materialEditor.DefaultShaderProperty(coverLayer1Smoothness, "Smoothness");
            materialEditor.DefaultShaderProperty(coverLayer1FadeStart, "Fade Start");
            materialEditor.DefaultShaderProperty(coverLayer1FadeDist, "Fade Distance");
            EditorGUI.indentLevel--;
        }
    }