/// <summary> /// Displays a font property field. /// </summary> /// <param name="position">Position.</param> /// <param name="fontProperty">Font property.</param> /// <param name="inheritingFrom">Style sheet from which the font is potentially inheriting.</param> public static void DisplayFontProperty( Rect position, SerializedProperty fontProperty, HyperTextStyles inheritingFrom ) { ValidationStatus status = ValidationStatus.None; s_ReusableLabel.text = fontProperty.displayName; s_ReusableLabel.tooltip = string.Empty; if (fontProperty.objectReferenceValue == null) { if (inheritingFrom != null && inheritingFrom.CascadedFont != null) { s_ReusableLabel.tooltip = string.Format( "Inheriting Font {0} from {1}.", inheritingFrom.CascadedFont.name, inheritingFrom.name ); } else { s_ReusableLabel.tooltip = "Font cannot be null."; status = ValidationStatus.Error; } } else if (!(fontProperty.objectReferenceValue as Font).dynamic) { s_ReusableLabel.tooltip = "Font size and style settings are only supported for dynamic fonts. " + "Only colors and offsets will be applied."; status = ValidationStatus.Warning; } else if (inheritingFrom != null && inheritingFrom.CascadedFont != null) { s_ReusableLabel.tooltip = string.Format( "Overriding Font {0} inherited from {1}.", inheritingFrom.CascadedFont.name, inheritingFrom.name ); status = ValidationStatus.Warning; } if ( string.IsNullOrEmpty(s_ReusableLabel.tooltip) && inheritingFrom != null && inheritingFrom.CascadedFont != null ) { s_ReusableLabel.tooltip = string.Format( "Assign a value to override Font {0} inherited from {1}", inheritingFrom.CascadedFont.name, inheritingFrom.name ); } switch (status) { case ValidationStatus.None: EditorGUI.PropertyField(position, fontProperty, s_ReusableLabel); break; default: EditorGUIX.DisplayPropertyFieldWithStatus( position, fontProperty, status, s_ReusableLabel, false, s_ReusableLabel.tooltip ); break; } }
/// <summary> /// Raises the draw tag keyword collections entry event. /// </summary> /// <param name="position">Position.</param> /// <param name="index">Index.</param> /// <param name="hyperTextProcessor"> /// A SerializedProperty representation of a <see cref="Candlelight.UI.HyperTextProcessor"/>. /// </param> /// <param name="getAllAssignedCollections"> /// A method to get all <see cref="Candlelight.KeywordCollection"/> objects assigned to the /// <see cref="Candlelight.UI.HyperTextProcessor"/>. /// </param> public static void OnDrawTagKeywordCollectionsEntry( Rect position, int index, SerializedProperty hyperTextProcessor, System.Func <IEnumerable <KeywordCollection> > getAllAssignedCollections ) { HyperTextStyles styles = hyperTextProcessor.FindPropertyRelative("m_Styles").objectReferenceValue as HyperTextStyles; if (styles != null) { styles.GetCascadedCustomTextStyles(s_CascadedTextStyles); } OnDrawKeywordCollectionClassEntry( position, hyperTextProcessor.FindPropertyRelative("m_TagKeywordCollections").GetArrayElementAtIndex(index), s_TagKeywordIdentifierGUIContent, styles == null ? s_EmptyIdentifierCollection : from style in s_CascadedTextStyles select style.Tag, ValidationStatus.Error, "text style with tag name", styles, getAllAssignedCollections() ); }
/// <summary> /// Raises the draw quad keyword collections entry event. /// </summary> /// <param name="position">Position.</param> /// <param name="index">Index.</param> /// <param name="hyperTextProcessor"> /// A SerializedProperty representation of a <see cref="Candlelight.UI.HyperTextProcessor"/>. /// </param> /// <param name="getAllAssignedCollections"> /// A method to get all <see cref="Candlelight.KeywordCollection"/> objects assigned to the /// <see cref="Candlelight.UI.HyperTextProcessor"/>. /// </param> public static void OnDrawQuadKeywordCollectionsEntry( Rect position, int index, SerializedProperty hyperTextProcessor, System.Func <IEnumerable <KeywordCollection> > getAllAssignedCollections ) { HyperTextStyles styles = hyperTextProcessor.FindPropertyRelative("m_Styles").objectReferenceValue as HyperTextStyles; if (styles != null) { styles.GetCascadedQuadStyles(ref s_CascadedQuadStyles); } OnDrawKeywordCollectionClassEntry( position, hyperTextProcessor.FindPropertyRelative("m_QuadKeywordCollections").GetArrayElementAtIndex(index), s_QuadKeywordIdentifierGUIContent, styles == null ? s_EmptyIdentifierCollection : from style in s_CascadedQuadStyles select style.ClassName, ValidationStatus.Error, "Specify a class name for the custom <quad> style with which this collection is associated.", "quad style with class name", styles, getAllAssignedCollections() ); }
/// <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(); }
/// <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(); }
/// <summary> /// Updates the validation statuses, labels, and tooltips for custom styles. /// </summary> private void UpdateCustomStyleGUIContents() { // rebuild inheritance m_InheritedLinks.Clear(); m_InheritedQuads.Clear(); m_InheritedTags.Clear(); m_InheritTooltip = ""; m_OverrideTooltip = ""; HyperTextStyles styles = this.target as HyperTextStyles; styles.GetInheritedStyles(s_InheritedStyles); m_ParentStyle = s_InheritedStyles.Where(s => s != null).LastOrDefault(); if (m_ParentStyle != null) { m_InheritedLinks = styles.GetInheritedLinkStyles(); m_InheritedQuads = styles.GetInheritedQuadStyles(); m_InheritedTags = styles.GetInheritedCustomTextStyles(); m_InheritTooltip = string.Format("will inherit from {0}", m_ParentStyle.name); m_OverrideTooltip = string.Format("overriding style inherited from {0}", m_ParentStyle.name); } // rebuild tooltips and icons m_LinkGUIContents.Clear(); using ( ListPool <HyperTextStyles.LinkSubclass> .Scope links = new ListPool <HyperTextStyles.LinkSubclass> .Scope() ) { styles.GetLinkStyles(links.List); for (int i = 0; i < links.List.Count; ++i) { m_LinkGUIContents[i] = ValidateIdentifier(links.List[i].Identifier, links.List); m_LinkGUIContents[i].Label = new GUIContent( string.IsNullOrEmpty(links.List[i].Identifier) ? string.Format("Link Style {0}", i) : string.Format("<a class=\"{0}\">", links.List[i].Identifier) ); UpdateValidatationStatusIfOverridingInheritedStyle( m_LinkGUIContents[i], links.List[i].Identifier, m_InheritedLinks ); } m_QuadGUIContents.Clear(); using (ListPool <HyperTextStyles.Quad> .Scope quads = new ListPool <HyperTextStyles.Quad> .Scope()) { styles.GetQuadStyles(quads.List); styles.GetCascadedLinkStyles(links.List); for (int i = 0; i < quads.List.Count; ++i) { m_QuadGUIContents[i] = ValidateIdentifier(quads.List[i].Identifier, quads.List); m_QuadGUIContents[i].Label = new GUIContent( string.IsNullOrEmpty(quads.List[i].Identifier) ? string.Format("Quad Style {0}", i) : string.Format("<quad class=\"{0}\">", quads.List[i].Identifier) ); if ( m_QuadGUIContents[i].Status == ValidationStatus.Okay && !string.IsNullOrEmpty(quads.List[i].LinkClassName) && !string.IsNullOrEmpty(quads.List[i].LinkId) ) { if ( links.List.Count( link => link.Identifier.ToLower() == quads.List[i].LinkClassName.ToLower() ) == 0 ) { m_QuadGUIContents[i].Status = ValidationStatus.Error; m_QuadGUIContents[i].StatusTooltip = string.Format( "No link style with class name {0} exists.", quads.List[i].LinkClassName ); } } UpdateValidatationStatusIfOverridingInheritedStyle( m_QuadGUIContents[i], quads.List[i].Identifier, m_InheritedQuads ); } } } m_TagGUIContents.Clear(); using (ListPool <HyperTextStyles.Text> .Scope tags = new ListPool <HyperTextStyles.Text> .Scope()) { styles.GetCustomTextStyles(tags.List); for (int i = 0; i < tags.List.Count; ++i) { m_TagGUIContents[i] = ValidateIdentifier(tags.List[i].Identifier, tags.List, "Tag"); m_TagGUIContents[i].Label = new GUIContent( string.IsNullOrEmpty(tags.List[i].Identifier) ? string.Format("Text Style {0}", i) : string.Format("<{0}>", tags.List[i].Identifier) ); UpdateValidatationStatusIfOverridingInheritedStyle( m_TagGUIContents[i], tags.List[i].Identifier, m_InheritedTags ); } } // update list of inherited style names based on current tab m_CurrentTabInheritedStyleNames.Clear(); switch (s_CustomStyleTabPreference.CurrentValue) { case CustomStyleTab.CustomTextStyles: m_CurrentTabInheritedStyleNames = ( from kv in m_InheritedTags where kv.Value != this.target select string.Format("{0} ({1})", kv.Key.Identifier, kv.Value.name) ).ToList(); break; case CustomStyleTab.LinkStyles: m_CurrentTabInheritedStyleNames = ( from kv in m_InheritedLinks where kv.Value != this.target select string.Format("{0} ({1})", kv.Key.Identifier, kv.Value.name) ).ToList(); break; case CustomStyleTab.QuadStyles: m_CurrentTabInheritedStyleNames = ( from kv in m_InheritedQuads where kv.Value != this.target select string.Format("{0} ({1})", kv.Key.Identifier, kv.Value.name) ).ToList(); break; } }
/// <summary> /// Raises the styles changed event. /// </summary> /// <param name="sender">Sender.</param> private void OnStylesChanged(HyperTextStyles sender) { UpdateCustomStyleGUIContents(); }
/// <summary> /// Raises the draw keyword collection class entry event. /// </summary> /// <param name="position">Position.</param> /// <param name="element">Element in the list.</param> /// <param name="identifierGUIContent">Identifier GUI content.</param> /// <param name="existingIdentifierNames">Existing identifier names.</param> /// <param name="defaultStatus">Default status.</param> /// <param name="missingStyleDescriptor">Missing style descriptor.</param> /// <param name="styles">Styles assigned to the <see cref="Candlelight.UI.HyperTextProcessor"/>.</param> /// <param name="assignedCollections"> /// All <see cref="Candlelight.KeywordCollection"/> objects assigned to the /// <see cref="Candlelight.UI.HyperTextProcessor"/>. /// </param> private static void OnDrawKeywordCollectionClassEntry( Rect position, SerializedProperty element, GUIContent identifierGUIContent, IEnumerable <string> existingIdentifierNames, ValidationStatus defaultStatus, string missingStyleDescriptor, HyperTextStyles styles, IEnumerable <KeywordCollection> assignedCollections ) { SerializedProperty collectionProperty = element.FindPropertyRelative("m_Collection"); ValidationStatus collectionStatus = ValidationStatus.Warning; if (collectionProperty.objectReferenceValue != null) { collectionStatus = assignedCollections.Count(item => item == collectionProperty.objectReferenceValue) > 1 ? ValidationStatus.Error : ValidationStatus.Okay; } string collectionTooltip; switch (collectionStatus) { case ValidationStatus.Error: collectionTooltip = "Specified keyword collection used for multiple different styles on this object."; break; case ValidationStatus.Warning: collectionTooltip = "Assign a keyword collection to automatically apply this style to keywords."; break; default: collectionTooltip = string.Empty; break; } string identifierName = element.FindPropertyRelative("m_ClassName").stringValue; ValidationStatus identifierStatus = defaultStatus; string identifierTooltip = string.Empty; if (!string.IsNullOrEmpty(identifierName)) { if (styles == null) { identifierTooltip = "No styles assigned to this object. Keywords from this collection will use default style"; identifierStatus = ValidationStatus.Warning; } else { int matches = existingIdentifierNames.Count(existingId => existingId == identifierName); if (matches == 1) { identifierStatus = ValidationStatus.Okay; } else { identifierStatus = ValidationStatus.Error; identifierTooltip = string.Format( "No custom {0} {1} found in {2}.", missingStyleDescriptor, identifierName, styles.name ); } } } bool useCollectionStatus = collectionStatus >= identifierStatus; EditorGUIX.DisplayPropertyFieldWithStatus( position, element, useCollectionStatus ? collectionStatus : identifierStatus, null, true, useCollectionStatus ? collectionTooltip : identifierTooltip ); }
/// <summary> /// Raises the draw keyword collection class entry event. /// </summary> /// <param name="position">Position.</param> /// <param name="element">Element in the list.</param> /// <param name="identifierGUIContent">Identifier GUI content.</param> /// <param name="existingIdentifierNames">Existing identifier names.</param> /// <param name="defaultStatus">Default status.</param> /// <param name="infoTooltip">Info tooltip.</param> /// <param name="missingStyleDescriptor">Missing style descriptor.</param> /// <param name="styles">Styles assigned to the <see cref="Candlelight.UI.HyperTextProcessor"/>.</param> /// <param name="assignedCollections"> /// All <see cref="Candlelight.KeywordCollection"/> objects assigned to the /// <see cref="Candlelight.UI.HyperTextProcessor"/>. /// </param> private static void OnDrawKeywordCollectionClassEntry( Rect position, SerializedProperty element, GUIContent identifierGUIContent, IEnumerable <string> existingIdentifierNames, ValidationStatus defaultStatus, string infoTooltip, string missingStyleDescriptor, HyperTextStyles styles, IEnumerable <KeywordCollection> assignedCollections ) { position.height = EditorGUIUtility.singleLineHeight; float oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 60f; position.width = (position.width - EditorGUIX.standardHorizontalSpacing) * 0.6f; SerializedProperty collectionProperty = element.FindPropertyRelative("m_Collection"); ValidationStatus collectionStatus = ValidationStatus.Warning; if (collectionProperty.objectReferenceValue != null) { collectionStatus = assignedCollections.Count(item => item == collectionProperty.objectReferenceValue) > 1 ? ValidationStatus.Error : ValidationStatus.Okay; } EditorGUIX.DisplayPropertyFieldWithStatus( position, collectionProperty, collectionStatus, null, true, collectionStatus == ValidationStatus.Okay ? "" : collectionStatus == ValidationStatus.Error ? string.Format( "Keyword collection {0} used for multiple different styles on this object.", collectionProperty.objectReferenceValue.name ) : "Assign a keyword collection to automatically apply this style to keywords." ); EditorGUIUtility.labelWidth = 40f; position.x += position.width; position.width *= 0.6666666667f; string identifierName = element.FindPropertyRelative("m_ClassName").stringValue; ValidationStatus status = defaultStatus; if (!string.IsNullOrEmpty(identifierName)) { if (styles == null) { infoTooltip = "No styles assigned to this object. Keywords from this collection will use default style"; status = ValidationStatus.Warning; } else { int matches = existingIdentifierNames.Count(existingId => existingId == identifierName); if (matches == 1) { status = ValidationStatus.Okay; infoTooltip = string.Empty; } else { status = ValidationStatus.Error; infoTooltip = string.Format( "No custom {0} {1} found in {2}.", missingStyleDescriptor, identifierName, styles.name ); } } } EditorGUIX.DisplayPropertyFieldWithStatus( position, element.FindPropertyRelative("m_ClassName"), status, identifierGUIContent, true, infoTooltip ); EditorGUIUtility.labelWidth = oldLabelWidth; }