protected bool DoPanelHeader(MaterialPanel panel, ShaderFeature feature, bool readState = true)
        {
            Rect controlRect = EditorGUILayout.GetControlRect(false, 22f);

            GUI.Label(controlRect, GUIContent.none, TMP_UIStyleManager.Group_Label);
            if (GUI.Button(new Rect(controlRect.x, controlRect.y, 250f, controlRect.height), panel.Label, TMP_UIStyleManager.Group_Label_Left))
            {
                panel.ToggleExpanded();
            }
            if (readState)
            {
                feature.ReadState(material);
            }
            EditorGUI.BeginChangeCheck();
            float labelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 70f;
            bool active = EditorGUI.Toggle(new Rect(controlRect.width - 90f, controlRect.y + 3f, 90f, 22f), new GUIContent("Enable ->"), feature.Active);

            EditorGUIUtility.labelWidth = labelWidth;
            if (EditorGUI.EndChangeCheck())
            {
                editor.RegisterPropertyChangeUndo(feature.undoLabel);
                feature.SetActive(active, material);
            }
            return(panel.Expanded);
        }
Exemple #2
0
 public void Clone(ShaderFeature src)
 {
     hide            = src.hide;
     readOnly        = src.readOnly;
     shaderGroupName = src.shaderGroupName;
     propertyName    = src.propertyName;
     type            = src.type;
     dependencyPropertys.Clone(src.dependencyPropertys);
 }
Exemple #3
0
        public static Dictionary <string, ShaderFeature> GetShaderFeatureList()
        {
            Dictionary <string, ShaderFeature> shaderFeatures = new Dictionary <string, ShaderFeature>();

            for (int i = 0; i < GlobalAssetsConfig.ShaderFeatures.Count; ++i)
            {
                ShaderFeature sf = GlobalAssetsConfig.ShaderFeatures[i];
                shaderFeatures[sf.name] = sf;
            }
            return(shaderFeatures);
        }
Exemple #4
0
        static TMP_SDFShaderGUI()
        {
            facePanel     = new MaterialPanel("Face", true);
            outlinePanel  = new MaterialPanel("Outline", true);
            underlayPanel = new MaterialPanel("Underlay", false);
            bevelPanel    = new MaterialPanel("Bevel", false);
            lightingPanel = new MaterialPanel("Lighting", false);
            bumpMapPanel  = new MaterialPanel("BumpMap", false);
            envMapPanel   = new MaterialPanel("EnvMap", false);
            glowPanel     = new MaterialPanel("Glow", false);
            debugPanel    = new MaterialPanel("Debug", false);

            outlineFeature = new ShaderFeature()
            {
                undoLabel = "Outline",
                keywords  = new string[] { "OUTLINE_ON" }
            };

            underlayFeature = new ShaderFeature()
            {
                undoLabel     = "Underlay",
                keywords      = new string[] { "UNDERLAY_ON", "UNDERLAY_INNER" },
                label         = new GUIContent("Underlay Type"),
                keywordLabels = new GUIContent[] {
                    new GUIContent("None"), new GUIContent("Normal"), new GUIContent("Inner")
                }
            };

            bevelFeature = new ShaderFeature()
            {
                undoLabel = "Bevel",
                keywords  = new string[] { "BEVEL_ON" }
            };

            glowFeature = new ShaderFeature()
            {
                undoLabel = "Glow",
                keywords  = new string[] { "GLOW_ON" }
            };

            maskFeature = new ShaderFeature()
            {
                undoLabel     = "Mask",
                keywords      = new string[] { "MASK_HARD", "MASK_SOFT" },
                label         = new GUIContent("Mask"),
                keywordLabels = new GUIContent[] {
                    new GUIContent("Mask Off"), new GUIContent("Mask Hard"), new GUIContent("Mask Soft")
                }
            };
        }
Exemple #5
0
 public static void GetGroupedShaderFeatureList(Dictionary <string, List <ShaderFeature> > groupedShaderFeatures)
 {
     groupedShaderFeatures.Clear();
     for (int i = 0; i < GlobalAssetsConfig.ShaderFeatures.Count; ++i)
     {
         ShaderFeature        sf = GlobalAssetsConfig.ShaderFeatures[i];
         List <ShaderFeature> sfList;
         if (!groupedShaderFeatures.TryGetValue(sf.shaderGroupName, out sfList))
         {
             sfList = new List <ShaderFeature>();
             groupedShaderFeatures[sf.shaderGroupName] = sfList;
         }
         sfList.Add(sf);
     }
 }
Exemple #6
0
        static TMP_SDFShaderGUI()
        {
            s_OutlineFeature = new ShaderFeature()
            {
                undoLabel = "Outline",
                keywords  = new[] { "OUTLINE_ON" }
            };

            s_UnderlayFeature = new ShaderFeature()
            {
                undoLabel     = "Underlay",
                keywords      = new[] { "UNDERLAY_ON", "UNDERLAY_INNER" },
                label         = new GUIContent("Underlay Type"),
                keywordLabels = new[]
                {
                    new GUIContent("None"), new GUIContent("Normal"), new GUIContent("Inner")
                }
            };

            s_BevelFeature = new ShaderFeature()
            {
                undoLabel = "Bevel",
                keywords  = new[] { "BEVEL_ON" }
            };

            s_GlowFeature = new ShaderFeature()
            {
                undoLabel = "Glow",
                keywords  = new[] { "GLOW_ON" }
            };

            s_MaskFeature = new ShaderFeature()
            {
                undoLabel     = "Mask",
                keywords      = new[] { "MASK_HARD", "MASK_SOFT" },
                label         = new GUIContent("Mask"),
                keywordLabels = new[]
                {
                    new GUIContent("Mask Off"), new GUIContent("Mask Hard"), new GUIContent("Mask Soft")
                }
            };
        }
        protected bool BeginPanel(string panel, ShaderFeature feature, bool expanded, bool readState = true)
        {
            EditorGUI.indentLevel = 0;

            if (readState)
            {
                feature.ReadState(m_Material);
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.BeginHorizontal();

            Rect r      = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 20, GUILayout.Width(20f)));
            bool active = EditorGUI.Toggle(r, feature.Active);

            if (EditorGUI.EndChangeCheck())
            {
                m_Editor.RegisterPropertyChangeUndo(feature.undoLabel);
                feature.SetActive(active, m_Material);
            }

            r        = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
            r.width += 6;

            bool enabled = GUI.enabled;

            GUI.enabled = true;
            expanded    = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelTitle);
            r.width    -= 10;
            EditorGUI.LabelField(r, new GUIContent(expanded ? s_PanelStateLabel[0] : s_PanelStateLabel[1]), TMP_UIStyleManager.rightLabel);
            GUI.enabled = enabled;

            GUILayout.EndHorizontal();

            EditorGUI.indentLevel += 1;
            EditorGUI.BeginDisabledGroup(!active);

            return(expanded);
        }
    //Toogle a Shader feature
    private void ToggleFeature(Material _matTarget, string label, ShaderFeature feature, float height = 20f, bool disableGroup = true)
    {
        var setter = _matTarget.IsKeywordEnabled(feature.GetString());
        var lbl    = (setter) ? ("Disable " + label) : ("Enable " + label);

        if (GUILayout.Button(lbl, GUILayout.Height(height)))
        {
            setter = !setter;
            if (setter)
            {
                _matTarget.EnableKeyword(feature.GetString());
            }
            else
            {
                _matTarget.DisableKeyword(feature.GetString());
            }
        }

        //Set this to false to not disabled the remaining GUI components
        if (disableGroup)
        {
            EditorGUI.BeginDisabledGroup(!setter);
        }
    }
 public static ShaderFeatureDetails Details(this ShaderFeature feature)
 {
     return(_details[feature]);
 }
 /// <summary>
 /// NextGenSprites:
 /// Returns a string to pass as ShaderProperty for controlling Material properties.
 /// </summary>
 /// <param name="slot">ShaderFeature Enum</param>
 /// <returns>string</returns>
 public static string GetString(this ShaderFeature slot)
 {
     return(ShaderKeywordProperties [(int)slot]);
 }
    //Toogle a Shader feature
    private void ToggleFeature(Material _matTarget, string label, ShaderFeature feature, float height = 20f, bool disableGroup = true)
    {
        var setter = _matTarget.IsKeywordEnabled(feature.GetString());
        var lbl = (setter) ? ("Disable " + label) : ("Enable " + label);
        if (GUILayout.Button(lbl, GUILayout.Height(height)))
        {
            setter = !setter;
            if (setter)
            {
                _matTarget.EnableKeyword(feature.GetString());
            }
            else
            {
                _matTarget.DisableKeyword(feature.GetString());
            }
        }

        //Set this to false to not disabled the remaining GUI components
        if (disableGroup)
            EditorGUI.BeginDisabledGroup(!setter);
    }