public override void OnInspectorGUI() { serializedObject.Update(); base.OnInspectorGUI(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_TextViewport); EditorGUILayout.PropertyField(m_TextComponent); TextMeshProUGUI text = null; if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null) { text = m_TextComponent.objectReferenceValue as TextMeshProUGUI; //if (text.supportRichText) //{ // EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning); //} } EditorGUI.BeginDisabledGroup(m_TextComponent == null || m_TextComponent.objectReferenceValue == null); // TEXT INPUT BOX EditorGUILayout.PropertyField(m_Text); // INPUT FIELD SETTINGS #region INPUT FIELD SETTINGS m_foldout.fontSettings = EditorGUILayout.Foldout(m_foldout.fontSettings, "Input Field Settings", true, TMP_UIStyleManager.boldFoldout); if (m_foldout.fontSettings) { EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_GlobalFontAsset, new GUIContent("Font Asset", "Set the Font Asset for both Placeholder and Input Field text object.")); if (EditorGUI.EndChangeCheck()) { TMP_InputField inputField = target as TMP_InputField; inputField.SetGlobalFontAsset(m_GlobalFontAsset.objectReferenceValue as TMP_FontAsset); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_GlobalPointSize, new GUIContent("Point Size", "Set the point size of both Placeholder and Input Field text object.")); if (EditorGUI.EndChangeCheck()) { TMP_InputField inputField = target as TMP_InputField; inputField.SetGlobalPointSize(m_GlobalPointSize.floatValue); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_CharacterLimit); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_ContentType); if (!m_ContentType.hasMultipleDifferentValues) { EditorGUI.indentLevel++; if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Standard || m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Autocorrected || m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_LineType); if (EditorGUI.EndChangeCheck()) { if (text != null) { if (m_LineType.enumValueIndex == (int)TMP_InputField.LineType.SingleLine) { text.enableWordWrapping = false; } else { text.enableWordWrapping = true; } } } } if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom) { EditorGUILayout.PropertyField(m_InputType); EditorGUILayout.PropertyField(m_KeyboardType); EditorGUILayout.PropertyField(m_CharacterValidation); if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.Regex) { EditorGUILayout.PropertyField(m_RegexValue); } else if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.CustomValidator) { EditorGUILayout.PropertyField(m_InputValidator); } } EditorGUI.indentLevel--; } EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_Placeholder); EditorGUILayout.PropertyField(m_VerticalScrollbar); if (m_VerticalScrollbar.objectReferenceValue != null) { EditorGUILayout.PropertyField(m_ScrollbarScrollSensitivity); } EditorGUILayout.PropertyField(m_CaretBlinkRate); EditorGUILayout.PropertyField(m_CaretWidth); EditorGUILayout.PropertyField(m_CustomCaretColor); m_CustomColor.target = m_CustomCaretColor.boolValue; if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded)) { EditorGUILayout.PropertyField(m_CaretColor); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(m_SelectionColor); EditorGUI.indentLevel--; } #endregion // CONTROL SETTINGS #region CONTROL SETTINGS m_foldout.extraSettings = EditorGUILayout.Foldout(m_foldout.extraSettings, "Control Settings", true, TMP_UIStyleManager.boldFoldout); if (m_foldout.extraSettings) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(m_OnFocusSelectAll, new GUIContent("OnFocus - Select All", "Should all the text be selected when the Input Field is selected.")); EditorGUILayout.PropertyField(m_ResetOnDeActivation, new GUIContent("Reset On DeActivation", "Should the Text and Caret position be reset when Input Field is DeActivated.")); EditorGUILayout.PropertyField(m_RestoreOriginalTextOnEscape, new GUIContent("Restore On ESC Key", "Should the original text be restored when pressing ESC.")); EditorGUILayout.PropertyField(m_HideMobileInput); EditorGUILayout.PropertyField(m_ReadOnly); EditorGUILayout.PropertyField(m_RichText); EditorGUILayout.PropertyField(m_RichTextEditingAllowed, new GUIContent("Allow Rich Text Editing")); EditorGUI.indentLevel--; } #endregion EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_OnValueChanged); EditorGUILayout.PropertyField(m_OnEndEdit); EditorGUILayout.PropertyField(m_OnSelect); EditorGUILayout.PropertyField(m_OnDeselect); EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { base.serializedObject.Update(); //((SelectableEditor)this).OnInspectorGUI(); base.OnInspectorGUI(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_TextViewport); EditorGUILayout.PropertyField(m_TextComponent); TextMeshProUGUI textMeshProUGUI = null; if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null) { textMeshProUGUI = (m_TextComponent.objectReferenceValue as TextMeshProUGUI); } EditorGUI.BeginDisabledGroup(m_TextComponent == null || m_TextComponent.objectReferenceValue == null); Rect controlRect = EditorGUILayout.GetControlRect(false, 25f); EditorGUIUtility.labelWidth = 130f; controlRect.y += 2f; GUI.Label(controlRect, "<b>TEXT INPUT BOX</b>" + (m_foldout.textInput ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label); if (GUI.Button(new Rect(controlRect.x, controlRect.y, controlRect.width - 150f, controlRect.height), GUIContent.none, GUI.skin.label)) { m_foldout.textInput = !m_foldout.textInput; } if (m_foldout.textInput) { EditorGUI.BeginChangeCheck(); m_Text.stringValue = EditorGUILayout.TextArea(m_Text.stringValue, TMP_UIStyleManager.TextAreaBoxEditor, GUILayout.Height(125f), GUILayout.ExpandWidth(true)); } if (GUILayout.Button("<b>INPUT FIELD SETTINGS</b>" + (m_foldout.fontSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.fontSettings = !m_foldout.fontSettings; } if (m_foldout.fontSettings) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_GlobalFontAsset, new GUIContent("Font Asset", "Set the Font Asset for both Placeholder and Input Field text object.")); if (EditorGUI.EndChangeCheck()) { TMP_InputField tMP_InputField = base.target as TMP_InputField; tMP_InputField.SetGlobalFontAsset(m_GlobalFontAsset.objectReferenceValue as TMP_FontAsset); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_GlobalPointSize, new GUIContent("Point Size", "Set the point size of both Placeholder and Input Field text object.")); if (EditorGUI.EndChangeCheck()) { TMP_InputField tMP_InputField2 = base.target as TMP_InputField; tMP_InputField2.SetGlobalPointSize(m_GlobalPointSize.floatValue); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_CharacterLimit); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_ContentType); if (!m_ContentType.hasMultipleDifferentValues) { EditorGUI.indentLevel++; if (m_ContentType.enumValueIndex == 0 || m_ContentType.enumValueIndex == 1 || m_ContentType.enumValueIndex == 9) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_LineType); if (EditorGUI.EndChangeCheck() && (Object)(object)textMeshProUGUI != null) { if (m_LineType.enumValueIndex == 0) { textMeshProUGUI.enableWordWrapping = false; } else { textMeshProUGUI.enableWordWrapping = true; } } } if (m_ContentType.enumValueIndex == 9) { EditorGUILayout.PropertyField(m_InputType); EditorGUILayout.PropertyField(m_KeyboardType); EditorGUILayout.PropertyField(m_CharacterValidation); if (m_CharacterValidation.enumValueIndex == 6) { EditorGUILayout.PropertyField(m_RegexValue); } else if (m_CharacterValidation.enumValueIndex == 8) { EditorGUILayout.PropertyField(m_InputValidator); } } EditorGUI.indentLevel--; } EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_Placeholder); EditorGUILayout.PropertyField(m_VerticalScrollbar); if (m_VerticalScrollbar.objectReferenceValue != null) { EditorGUILayout.PropertyField(m_ScrollbarScrollSensitivity); } EditorGUILayout.PropertyField(m_CaretBlinkRate); EditorGUILayout.PropertyField(m_CaretWidth); EditorGUILayout.PropertyField(m_CustomCaretColor); m_CustomColor.target = m_CustomCaretColor.boolValue; if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded)) { EditorGUILayout.PropertyField(m_CaretColor); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(m_SelectionColor); } if (GUILayout.Button("<b>CONTROL SETTINGS</b>" + (m_foldout.extraSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.extraSettings = !m_foldout.extraSettings; } if (m_foldout.extraSettings) { EditorGUILayout.PropertyField(m_OnFocusSelectAll, new GUIContent("OnFocus - Select All", "Should all the text be selected when the Input Field is selected.")); EditorGUILayout.PropertyField(m_ResetOnDeActivation, new GUIContent("Reset On DeActivation", "Should the Text and Caret position be reset when Input Field is DeActivated.")); EditorGUILayout.PropertyField(m_RestoreOriginalTextOnEscape, new GUIContent("Restore On ESC Key", "Should the original text be restored when pressing ESC.")); EditorGUILayout.PropertyField(m_HideMobileInput); EditorGUILayout.PropertyField(m_ReadOnly); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_RichText); EditorGUIUtility.labelWidth = 140f; EditorGUILayout.PropertyField(m_RichTextEditingAllowed, new GUIContent("Allow Rich Text Editing")); EditorGUIUtility.labelWidth = 130f; EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_OnValueChanged); EditorGUILayout.PropertyField(m_OnEndEdit); EditorGUILayout.PropertyField(m_OnSelect); EditorGUILayout.PropertyField(m_OnDeselect); EditorGUI.EndDisabledGroup(); base.serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); base.OnInspectorGUI(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_TextViewport); EditorGUILayout.PropertyField(m_TextComponent); TextMeshProUGUI text = null; if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null) { text = m_TextComponent.objectReferenceValue as TextMeshProUGUI; //if (text.supportRichText) //{ // EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning); //} } EditorGUI.BeginDisabledGroup(m_TextComponent == null || m_TextComponent.objectReferenceValue == null); // TEXT INPUT BOX Rect rect = EditorGUILayout.GetControlRect(false, 25); EditorGUIUtility.labelWidth = 130f; //EditorGUIUtility.fieldWidth; rect.y += 2; GUI.Label(rect, "<b>TEXT INPUT BOX</b>" + (m_foldout.textInput ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label); if (GUI.Button(new Rect(rect.x, rect.y, rect.width - 150, rect.height), GUIContent.none, GUI.skin.label)) { m_foldout.textInput = !m_foldout.textInput; } // Toggle showing Rich Tags //GUI.Label(new Rect(rect.width - 125, rect.y + 4, 125, 24), "<i>Enable RTL Editor</i>", toggleStyle); if (m_foldout.textInput) { EditorGUI.BeginChangeCheck(); m_Text.stringValue = EditorGUILayout.TextArea(m_Text.stringValue, TMP_UIStyleManager.TextAreaBoxEditor, GUILayout.Height(125), GUILayout.ExpandWidth(true)); } // INPUT FIELD SETTINGS #region INPUT FIELD SETTINGS if (GUILayout.Button("<b>INPUT FIELD SETTINGS</b>" + (m_foldout.fontSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.fontSettings = !m_foldout.fontSettings; } if (m_foldout.fontSettings) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_GlobalFontAsset, new GUIContent("Font Asset", "Set the Font Asset for both Placeholder and Input Field text object.")); if (EditorGUI.EndChangeCheck()) { TMP_InputField inputField = target as TMP_InputField; inputField.SetGlobalFontAsset(m_GlobalFontAsset.objectReferenceValue as TMP_FontAsset); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_GlobalPointSize, new GUIContent("Point Size", "Set the point size of both Placeholder and Input Field text object.")); if (EditorGUI.EndChangeCheck()) { TMP_InputField inputField = target as TMP_InputField; inputField.SetGlobalPointSize(m_GlobalPointSize.floatValue); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_CharacterLimit); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_ContentType); if (!m_ContentType.hasMultipleDifferentValues) { EditorGUI.indentLevel++; if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Standard || m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Autocorrected || m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_LineType); if (EditorGUI.EndChangeCheck()) { if (text != null) { if (m_LineType.enumValueIndex == (int)TMP_InputField.LineType.SingleLine) { text.enableWordWrapping = false; } else { text.enableWordWrapping = true; } } } } if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom) { EditorGUILayout.PropertyField(m_InputType); EditorGUILayout.PropertyField(m_KeyboardType); EditorGUILayout.PropertyField(m_CharacterValidation); if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.Regex) { EditorGUILayout.PropertyField(m_RegexValue); } else if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.CustomValidator) { EditorGUILayout.PropertyField(m_InputValidator); } } EditorGUI.indentLevel--; } EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_Placeholder); EditorGUILayout.PropertyField(m_VerticalScrollbar); if (m_VerticalScrollbar.objectReferenceValue != null) { EditorGUILayout.PropertyField(m_ScrollbarScrollSensitivity); } EditorGUILayout.PropertyField(m_CaretBlinkRate); EditorGUILayout.PropertyField(m_CaretWidth); EditorGUILayout.PropertyField(m_CustomCaretColor); m_CustomColor.target = m_CustomCaretColor.boolValue; if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded)) { EditorGUILayout.PropertyField(m_CaretColor); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(m_SelectionColor); } #endregion // CONTROL SETTINGS #region CONTROL SETTINGS if (GUILayout.Button("<b>CONTROL SETTINGS</b>" + (m_foldout.extraSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.extraSettings = !m_foldout.extraSettings; } if (m_foldout.extraSettings) { EditorGUILayout.PropertyField(m_OnFocusSelectAll, new GUIContent("OnFocus - Select All", "Should all the text be selected when the Input Field is selected.")); EditorGUILayout.PropertyField(m_ResetOnDeActivation, new GUIContent("Reset On DeActivation", "Should the Text and Caret position be reset when Input Field is DeActivated.")); EditorGUILayout.PropertyField(m_RestoreOriginalTextOnEscape, new GUIContent("Restore On ESC Key", "Should the original text be restored when pressing ESC.")); EditorGUILayout.PropertyField(m_HideMobileInput); EditorGUILayout.PropertyField(m_ReadOnly); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_RichText); EditorGUIUtility.labelWidth = 140f; EditorGUILayout.PropertyField(m_RichTextEditingAllowed, new GUIContent("Allow Rich Text Editing")); EditorGUIUtility.labelWidth = 130f; EditorGUILayout.EndHorizontal(); } #endregion EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_OnValueChanged); EditorGUILayout.PropertyField(m_OnEndEdit); EditorGUILayout.PropertyField(m_OnSelect); EditorGUILayout.PropertyField(m_OnDeselect); EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }