static int DoVerticalAligmentControl(Rect position, SerializedProperty alignment) { var selected = TMP_EditorUtility.GetVerticalAlignmentGridValue(alignment.intValue); var values = new bool[6]; values[selected] = true; if (alignment.hasMultipleDifferentValues) { foreach (var obj in alignment.serializedObject.targetObjects) { var text = obj as TMP_Text; if (text != null) { values[TMP_EditorUtility.GetVerticalAlignmentGridValue((int)text.alignment)] = true; } } } position.width = k_AlignmentButtonWidth; for (var i = 0; i < values.Length; i++) { var oldValue = values[i]; var newValue = TMP_EditorUtility.EditorToggle(position, oldValue, TMP_UIStyleManager.alignContentB[i], i == 0 ? TMP_UIStyleManager.alignmentButtonLeft : (i == 5 ? TMP_UIStyleManager.alignmentButtonRight : TMP_UIStyleManager.alignmentButtonMid)); if (newValue != oldValue) { selected = i; } position.x += position.width; } return(selected); }
protected bool BeginPanel(string panel, bool expanded) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18)); r.x += 20; r.width += 6; bool enabled = GUI.enabled; GUI.enabled = true; expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelTitle); GUI.enabled = enabled; EditorGUI.indentLevel += 1; EditorGUI.BeginDisabledGroup(false); return(expanded); }
protected bool BeginPanel(string panel, ShaderFeature feature, bool expanded, bool readState = true) { 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); GUI.enabled = enabled; GUILayout.EndHorizontal(); EditorGUI.indentLevel += 1; EditorGUI.BeginDisabledGroup(!active); return(expanded); }