Beispiel #1
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();
        }
Beispiel #2
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();
        }