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); }