/// <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);
        }
Example #2
0
 /// <summary>
 /// Raises the draw inherited style entry event.
 /// </summary>
 /// <param name="position">Position.</param>
 /// <param name="index">Index.</param>
 /// <param name="isActive">If set to <see langword="true"/> is active.</param>
 /// <param name="isFocused">If set to <see langword="true"/> is focused.</param>
 private void OnDrawInheritedStyleEntry(Rect position, int index, bool isActive, bool isFocused)
 {
     position.height      = EditorGUIUtility.singleLineHeight;
     s_ReusableLabel.text =
         string.Format("Style {0}{1}", index, index == m_InheritedStyles.count - 1 ? " (Parent)" : "");
     EditorGUI.BeginChangeCheck();
     {
         EditorGUIX.DisplayScriptableObjectPropertyFieldWithButton <HyperTextStyles>(
             position, m_InheritedStyles.serializedProperty.GetArrayElementAtIndex(index), s_ReusableLabel
             );
     }
     if (EditorGUI.EndChangeCheck())
     {
         UpdateCustomStyleGUIContents();
     }
 }
        /// <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);
        }
Example #4
0
        /// <summary>
        /// Raises the inspector GUI event.
        /// </summary>
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();
            m_AssignedCollections = HyperTextProcessorDrawer.GetAllCollections(m_TextProcessorProperty);
            EditorGUILayout.PropertyField(m_ScriptProperty);
            EditorGUILayout.PropertyField(m_InteractableProperty);
            Rect position =
                EditorGUILayout.GetControlRect(true, EditorGUI.GetPropertyHeight(m_LinkHitboxPaddingProperty));

            DisplayOverridableProperty(
                position, m_LinkHitboxPaddingProperty, m_OverrideLinkHitboxProperty, m_StylesProperty
                );
            bool hadStyles = m_StylesProperty.objectReferenceValue != null;

            if (EditorGUIX.DisplayScriptableObjectPropertyFieldWithButton <HyperTextStyles>(m_StylesProperty))
            {
                HyperTextStyles newStyles = m_StylesProperty.objectReferenceValue as HyperTextStyles;
                if (newStyles != null && m_FontDataProperty.FindPropertyRelative("m_Font").objectReferenceValue != null)
                {
                    newStyles.Font = m_FontDataProperty.FindPropertyRelative("m_Font").objectReferenceValue as Font;
                }
            }
            if (
                !hadStyles &&
                m_StylesProperty.objectReferenceValue != null &&
                (m_StylesProperty.objectReferenceValue as HyperTextStyles).CascadedFont != null
                )
            {
                m_FontDataProperty.FindPropertyRelative("m_Font").objectReferenceValue = null;
            }
            // NOTE: LayoutList() doesn't use proper vertical spacing
            Rect rect = EditorGUILayout.GetControlRect(false, m_LinkKeywordCollections.GetHeight());

            m_LinkKeywordCollections.DoList(rect);
            rect = EditorGUILayout.GetControlRect(false, m_TagKeywordCollections.GetHeight());
            m_TagKeywordCollections.DoList(rect);
            rect = EditorGUILayout.GetControlRect(false, m_QuadKeywordCollections.GetHeight());
            m_QuadKeywordCollections.DoList(rect);
            bool isTextInputSourceAssigned =
                m_InputTextSourceProperty.objectReferenceValue != null ||
                (this.target as HyperText).InputTextSource != null;

            EditorGUI.BeginDisabledGroup(isTextInputSourceAssigned);
            {
                EditorGUILayout.PropertyField(m_TextProperty);
            }
            EditorGUI.EndDisabledGroup();
            if (isTextInputSourceAssigned)
            {
                EditorGUIX.DisplayPropertyFieldWithStatus(
                    m_InputTextSourceProperty,
                    ValidationStatus.Warning,
                    s_InputTextSourceLabel,
                    false,
                    s_InputTextSourceLabel.tooltip
                    );
            }
            else
            {
                EditorGUILayout.PropertyField(m_InputTextSourceProperty, s_InputTextSourceLabel);
            }
            EditorGUILayout.LabelField("Character", EditorStyles.boldLabel);
            ++EditorGUI.indentLevel;
            position = EditorGUILayout.GetControlRect();
            DisplayFontProperty(position, m_FontProperty, m_StylesProperty.objectReferenceValue as HyperTextStyles);
            position = EditorGUILayout.GetControlRect();
            DisplayOverridableProperty(position, m_FontStyleProperty, m_OverrideFontStyleProperty, m_StylesProperty);
            position = EditorGUILayout.GetControlRect();
            DisplayOverridableProperty(position, m_FontSizeProperty, m_OverrideFontSizeProperty, m_StylesProperty);
            position = EditorGUILayout.GetControlRect();
            DisplayOverridableProperty(
                position, m_LineSpacingProperty, m_OverrideLineSpacingProperty, m_StylesProperty
                );
            EditorGUILayout.PropertyField(m_RichTextProperty);
            --EditorGUI.indentLevel;
            EditorGUILayout.LabelField("Paragraph", EditorStyles.boldLabel);
            ++EditorGUI.indentLevel;
            EditorGUILayout.PropertyField(m_AlignmentProperty);
            EditorGUILayout.PropertyField(m_HorizontalOverflowProperty);
            EditorGUILayout.PropertyField(m_VerticalOverflowProperty);
            EditorGUILayout.PropertyField(m_BestFitProperty);
            --EditorGUI.indentLevel;
            position = EditorGUILayout.GetControlRect();
            DisplayOverridableProperty(position, m_ColorProperty, m_OverrideFontColorProperty, m_StylesProperty);
            EditorGUILayout.PropertyField(m_MaterialProperty, s_MaterialLabel);
            EditorGUILayout.LabelField("Events", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(m_OnClickProperty);
            EditorGUILayout.PropertyField(m_OnEnterProperty);
            EditorGUILayout.PropertyField(m_OnExitProperty);
            EditorGUILayout.PropertyField(m_OnPressProperty);
            EditorGUILayout.PropertyField(m_OnReleaseProperty);
            this.serializedObject.ApplyModifiedProperties();
        }
Example #5
0
        /// <summary>
        /// Raises the inspector GUI event.
        /// </summary>
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();
            m_AssignedCollections = HyperTextProcessorDrawer.GetAllCollections(m_TextProcessor);
            EditorGUILayout.PropertyField(m_Script);
            if (
                m_RaycastTargetWarningStatus != ValidationStatus.None &&
                DisplayErrorMessageWithFixButton(
                    m_RaycastTargetWarningMessage,
                    s_FixRaycastTargetLabel,
                    m_RaycastTargetWarningStatus == ValidationStatus.Warning ? MessageType.Warning : MessageType.Error
                    )
                )
            {
                m_RaycastTarget.boolValue = !m_RaycastTarget.boolValue;
                this.serializedObject.ApplyModifiedProperties();
            }
            EditorGUILayout.PropertyField(m_Interactable);
            ++EditorGUI.indentLevel;
            EditorGUI.BeginDisabledGroup(!m_Interactable.boolValue);
            {
                EditorGUILayout.PropertyField(m_OpenURLPatterns, s_OpenURLPatternsLabel);
            }
            EditorGUI.EndDisabledGroup();
            --EditorGUI.indentLevel;
            Rect position = EditorGUILayout.GetControlRect(true, EditorGUI.GetPropertyHeight(m_LinkHitboxPadding));

            DisplayOverridableProperty(
                position, m_LinkHitboxPadding, m_ShouldOverrideStylesLinkHitboxPadding, m_Styles
                );
            bool hadStyles = m_Styles.objectReferenceValue != null;

            if (EditorGUIX.DisplayScriptableObjectPropertyFieldWithButton <HyperTextStyles>(m_Styles))
            {
                HyperTextStyles newStyles = m_Styles.objectReferenceValue as HyperTextStyles;
                if (newStyles != null)
                {
                    if (m_Font.objectReferenceValue != null)
                    {
                        newStyles.Font = m_Font.objectReferenceValue as Font;
                    }
                    newStyles.DefaultFontStyle = (FontStyle)m_FontStyle.enumValueIndex;
                    newStyles.DefaultTextColor = m_Color.colorValue;
                    newStyles.FontSize         = m_FontSize.intValue;
                }
            }
            if (
                !hadStyles &&
                m_Styles.objectReferenceValue != null &&
                (m_Styles.objectReferenceValue as HyperTextStyles).CascadedFont != null
                )
            {
                m_Font.objectReferenceValue = null;
            }
            // NOTE: LayoutList() doesn't use proper vertical spacing
            ++EditorGUI.indentLevel;
            int  indent = EditorGUI.indentLevel;
            Rect rect   =
                EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(false, m_LinkKeywordCollections.GetHeight()));

            EditorGUI.indentLevel = 0;
            m_LinkKeywordCollections.DoList(rect);
            EditorGUI.indentLevel = indent;
            rect =
                EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(false, m_TagKeywordCollections.GetHeight()));
            EditorGUI.indentLevel = 0;
            m_TagKeywordCollections.DoList(rect);
            EditorGUI.indentLevel = indent;
            rect =
                EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(false, m_QuadKeywordCollections.GetHeight()));
            EditorGUI.indentLevel = 0;
            m_QuadKeywordCollections.DoList(rect);
            EditorGUI.indentLevel = indent;
            --EditorGUI.indentLevel;
            bool isTextInputSourceAssigned =
                m_InputTextSourceObject.objectReferenceValue != null ||
                (this.target as HyperText).InputTextSource != null;

            EditorGUI.BeginDisabledGroup(isTextInputSourceAssigned);
            {
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.PropertyField(m_Text);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    ApplyModificationsAndUpdateGUIContents();
                }
            }
            EditorGUI.EndDisabledGroup();
            if (isTextInputSourceAssigned)
            {
                EditorGUIX.DisplayPropertyFieldWithStatus(
                    m_InputTextSourceObject,
                    ValidationStatus.Warning,
                    s_InputTextSourceLabel,
                    false,
                    s_InputTextSourceLabel.tooltip
                    );
            }
            else
            {
                EditorGUILayout.PropertyField(m_InputTextSourceObject, s_InputTextSourceLabel);
            }
            EditorGUILayout.LabelField("Character", EditorStyles.boldLabel);
            ++EditorGUI.indentLevel;
            position = EditorGUILayout.GetControlRect();
            DisplayFontProperty(position, m_Font, m_Styles.objectReferenceValue as HyperTextStyles);
            position = EditorGUILayout.GetControlRect();
            DisplayOverridableProperty(position, m_FontStyle, m_ShouldOverrideStylesFontStyle, m_Styles);
            position = EditorGUILayout.GetControlRect();
            DisplayOverridableProperty(position, m_FontSize, m_ShouldOverrideStylesFontSize, m_Styles);
            position = EditorGUILayout.GetControlRect();
            DisplayOverridableProperty(
                position, m_LineSpacing, m_ShouldOverrideStylesLineSpacing, m_Styles
                );
            EditorGUILayout.PropertyField(m_RichText);
            --EditorGUI.indentLevel;
            EditorGUILayout.LabelField("Paragraph", EditorStyles.boldLabel);
            ++EditorGUI.indentLevel;
            EditorGUILayout.PropertyField(m_Alignment);
            if (m_AlignByGeometry != null)
            {
                EditorGUILayout.PropertyField(m_AlignByGeometry);
            }
            EditorGUILayout.PropertyField(m_HorizontalOverflow);
            EditorGUILayout.PropertyField(m_VerticalOverflow);
            EditorGUILayout.PropertyField(m_BestFit);
            if (m_BestFit.boolValue)
            {
                ++EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_MinSize);
                EditorGUILayout.PropertyField(m_MaxSize);
                --EditorGUI.indentLevel;
            }
            --EditorGUI.indentLevel;
            position = EditorGUILayout.GetControlRect();
            DisplayOverridableProperty(position, m_Color, m_ShouldOverrideStylesFontColor, m_Styles);
            EditorGUILayout.PropertyField(m_Material, s_MaterialLabel);
            EditorGUILayout.PropertyField(m_QuadMaterial);
            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.PropertyField(m_RaycastTarget);
                if (!string.IsNullOrEmpty(m_RaycastTargetWarningMessage))
                {
                    position       = GUILayoutUtility.GetLastRect();
                    position.x    += position.width - EditorGUIUtility.singleLineHeight;
                    position.width = EditorGUIUtility.singleLineHeight;
                    EditorGUIX.DisplayValidationStatusIcon(
                        position, m_RaycastTargetWarningStatus, m_RaycastTargetWarningMessage
                        );
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                ApplyModificationsAndUpdateGUIContents();
            }
            if (m_SubclassProperties.Count > 0)
            {
                EditorGUILayout.LabelField("Other Properties", EditorStyles.boldLabel);
                ++EditorGUI.indentLevel;
                for (int i = 0; i < m_SubclassProperties.Count; ++i)
                {
                    EditorGUILayout.PropertyField(m_SubclassProperties[i]);
                }
                --EditorGUI.indentLevel;
            }
            EditorGUILayout.LabelField("Events", EditorStyles.boldLabel);
            ++EditorGUI.indentLevel;
            DisplayEventProperty(m_ClickedLink);
            DisplayEventProperty(m_EnteredLink);
            DisplayEventProperty(m_ExitedLink);
            DisplayEventProperty(m_PressedLink);
            DisplayEventProperty(m_ReleasedLink);
            --EditorGUI.indentLevel;
            this.serializedObject.ApplyModifiedProperties();
        }