/// <summary> /// Raises the GUI event. /// </summary> /// <param name="position">Position.</param> /// <param name="property">Property.</param> /// <param name="label">Label.</param> public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Initialize(property); SerializedProperty inputText = property.FindPropertyRelative("m_InputText"); SerializedProperty styles = property.FindPropertyRelative("m_Styles"); SerializedProperty supportRichText = property.FindPropertyRelative("m_IsRichTextDesired"); Rect entirePosition = position; position.height = (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 2f; EditorGUI.PropertyField(position, inputText); position.x = entirePosition.x; position.width = entirePosition.width; position.y += position.height + EditorGUIUtility.standardVerticalSpacing; position.height = EditorGUIUtility.singleLineHeight; EditorGUIX.DisplayScriptableObjectPropertyFieldWithButton <HyperTextStyles>(position, styles); position.y += position.height + EditorGUIUtility.standardVerticalSpacing; HyperTextEditor.DisplayOverridableProperty( position, property.FindPropertyRelative("m_ReferenceFontSize"), property.FindPropertyRelative("m_ShouldOverrideStylesFontSize"), styles ); position.x = entirePosition.x; position.width = entirePosition.width; position.y += position.height + EditorGUIUtility.standardVerticalSpacing; EditorGUIX.DisplayPropertyFieldWithStatus( position, supportRichText, ValidationStatus.Info, new GUIContent("Output Rich Text"), true, "Disable if the destination does not support rendering rich text." ); position.y += position.height + EditorGUIUtility.standardVerticalSpacing; ++EditorGUI.indentLevel; EditorGUIX.DisplayPropertyFieldWithStatus( position, property.FindPropertyRelative("m_IsDynamicFontDesired"), supportRichText.boolValue ? ValidationStatus.Info : ValidationStatus.Warning, new GUIContent("<size> Tags"), true, string.Format( "Disable if the destination uses a non-dynamic font.{0}", supportRichText.boolValue ? "" : "\n\nYou must enable rich text to output <size> tags." ) ); --EditorGUI.indentLevel; position.y += position.height + EditorGUIUtility.standardVerticalSpacing; position.height = m_LinkCollections[property.propertyPath].GetHeight(); m_LinkCollections[property.propertyPath].DoList(position); position.y += position.height; position.height = m_TagCollections[property.propertyPath].GetHeight(); m_TagCollections[property.propertyPath].DoList(position); position.y += position.height; position.height = m_QuadCollections[property.propertyPath].GetHeight(); m_QuadCollections[property.propertyPath].DoList(position); }
/// <summary> /// Displays a property field with an override property checkbox and status icon if a parent style is found. /// </summary> /// <param name="position">Position.</param> /// <param name="property">Property to display.</param> /// <param name="overrideProperty"> /// Property specifying whether the other property is overriding an inherited one. Object reference properties /// are assumed to override if they have a value assigned. /// </param> private void DisplayOverridableProperty( Rect position, SerializedProperty property, SerializedProperty overrideProperty ) { HyperTextEditor.DisplayOverridableProperty( position: position, property: property, overrideProperty: overrideProperty, displayCheckbox: m_ParentStyle != null, inheritTooltip: m_InheritTooltip, overrideTooltip: m_OverrideTooltip ); }
/// <summary> /// Raises the inspector GUI event. /// </summary> public override void OnInspectorGUI() { this.serializedObject.Update(); EditorGUILayout.PropertyField(m_ScriptProperty); EditorGUILayout.PropertyField(m_NameProperty); EditorGUI.BeginChangeCheck(); { m_InheritedStyles.DoLayoutList(); } if (EditorGUI.EndChangeCheck()) { UpdateCustomStyleGUIContents(); } Rect position = EditorGUILayout.GetControlRect(); HyperTextEditor.DisplayFontProperty(position, m_FontProperty, m_ParentStyle); position = EditorGUILayout.GetControlRect(); DisplayOverridableProperty(position, m_FontSizeProperty, m_FontSizeOverrideProperty); position = EditorGUILayout.GetControlRect(); DisplayOverridableProperty(position, m_LineSpacingProperty, m_LineSpacingOverrideProperty); position = EditorGUILayout.GetControlRect(); DisplayOverridableProperty(position, m_DefaultFontStyleProperty, m_DefaultFontStyleOverrideProperty); position = EditorGUILayout.GetControlRect(); DisplayOverridableProperty(position, m_DefaultTextColorProperty, m_DefaultTextColorOverrideProperty); DisplayOverridableProperty( EditorGUILayout.GetControlRect(true, HyperTextLinkStyleDrawer.PropertyHeight), m_DefaultLinkStyleProperty, m_DefaultLinkStyleOverrideProperty ); position = EditorGUILayout.GetControlRect(true, EditorGUI.GetPropertyHeight(m_LinkHitboxPaddingProperty)); DisplayOverridableProperty(position, m_LinkHitboxPaddingProperty, m_LinkHitboxPaddingOverrideProperty); EditorGUILayout.LabelField("Custom Styles"); ++EditorGUI.indentLevel; CustomStyleTab oldTab = s_CustomStyleTabPreference.CurrentValue; EditorGUI.BeginChangeCheck(); { s_CustomStyleTabPreference.CurrentValue = (CustomStyleTab)EditorGUIX.DisplayTabGroup( (int)s_CustomStyleTabPreference.CurrentValue, s_CustomStyleTabLabels, m_CustomStyleTabContents ); } if (EditorGUI.EndChangeCheck() && oldTab != s_CustomStyleTabPreference.CurrentValue) { UpdateCustomStyleGUIContents(); } --EditorGUI.indentLevel; this.serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Raises the GUI event. /// </summary> /// <param name="position">Position.</param> /// <param name="property">Property.</param> /// <param name="label">Label.</param> public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Initialize(property); SerializedProperty inputText = property.FindPropertyRelative("m_InputText"); SerializedProperty styles = property.FindPropertyRelative("m_Styles"); SerializedProperty supportRichText = property.FindPropertyRelative("m_IsRichTextDesired"); Rect entirePosition = position; position.height = (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 2f; EditorGUI.PropertyField(position, inputText); position.x = entirePosition.x; position.width = entirePosition.width; position.y += position.height + EditorGUIUtility.standardVerticalSpacing; position.height = EditorGUIUtility.singleLineHeight; EditorGUIX.DisplayScriptableObjectPropertyFieldWithButton <HyperTextStyles>(position, styles); position.y += position.height + EditorGUIUtility.standardVerticalSpacing; HyperTextEditor.DisplayOverridableProperty( position, property.FindPropertyRelative("m_ReferenceFontSize"), property.FindPropertyRelative("m_ShouldOverrideStylesFontSize"), styles ); position.x = entirePosition.x; position.width = entirePosition.width; position.y += position.height + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(position, supportRichText, s_RichTextLabel); position.y += position.height + EditorGUIUtility.standardVerticalSpacing; ++EditorGUI.indentLevel; EditorGUI.BeginDisabledGroup(!supportRichText.boolValue); { EditorGUI.PropertyField( position, property.FindPropertyRelative("m_IsDynamicFontDesired"), s_DynamicFontLabel ); } EditorGUI.EndDisabledGroup(); --EditorGUI.indentLevel; position.y += position.height + EditorGUIUtility.standardVerticalSpacing; position.height = m_LinkCollections[property.propertyPath].GetHeight(); m_LinkCollections[property.propertyPath].DoList(position); position.y += position.height; position.height = m_TagCollections[property.propertyPath].GetHeight(); m_TagCollections[property.propertyPath].DoList(position); position.y += position.height; position.height = m_QuadCollections[property.propertyPath].GetHeight(); m_QuadCollections[property.propertyPath].DoList(position); }