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); }
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); }
private void DoDebugPanel() { EditorGUI.indentLevel++; DoTexture2D("_MainTex", "Font Atlas"); DoFloat("_GradientScale", "Gradient Scale"); DoFloat("_TextureWidth", "Texture Width"); DoFloat("_TextureHeight", "Texture Height"); DoEmptyLine(); DoFloat("_ScaleX", "Scale X"); DoFloat("_ScaleY", "Scale Y"); DoSlider("_PerspectiveFilter", "Perspective Filter"); DoEmptyLine(); DoFloat("_VertexOffsetX", "Offset X"); DoFloat("_VertexOffsetY", "Offset Y"); if (material.HasProperty(ShaderUtilities.ID_MaskCoord)) { DoEmptyLine(); maskFeature.ReadState(material); maskFeature.DoPopup(editor, material); if (maskFeature.Active) { DoMaskSubgroup(); } DoEmptyLine(); DoVector("_ClipRect", "Clip Rect", TMP_BaseShaderGUI.lbrtVectorLabels); } else if (material.HasProperty("_MaskTex")) { DoMaskTexSubgroup(); } else if (material.HasProperty(ShaderUtilities.ID_MaskSoftnessX)) { DoEmptyLine(); DoFloat("_MaskSoftnessX", "Softness X"); DoFloat("_MaskSoftnessY", "Softness Y"); DoVector("_ClipRect", "Clip Rect", TMP_BaseShaderGUI.lbrtVectorLabels); } if (material.HasProperty(ShaderUtilities.ID_StencilID)) { DoEmptyLine(); DoFloat("_Stencil", "Stencil ID"); DoFloat("_StencilComp", "Stencil Comp"); } DoEmptyLine(); EditorGUI.BeginChangeCheck(); bool flag = EditorGUILayout.Toggle("Use Ratios?", !material.IsKeywordEnabled("RATIOS_OFF")); if (EditorGUI.EndChangeCheck()) { editor.RegisterPropertyChangeUndo("Use Ratios"); if (flag) { material.DisableKeyword("RATIOS_OFF"); } else { material.EnableKeyword("RATIOS_OFF"); } } EditorGUI.BeginDisabledGroup(true); DoFloat("_ScaleRatioA", "Scale Ratio A"); DoFloat("_ScaleRatioB", "Scale Ratio B"); DoFloat("_ScaleRatioC", "Scale Ratio C"); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; }