/// <inheritdoc/> public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { this.Initialize(property); this.UpdateDictionaryErrors(); float listHeight = this.ListControl.CalculateListHeight(this.ListAdaptor); float newInputHeight = NewInputPlaceholderHeight; float errorOutputHeight = this.errors.Sum(error => EditorStyles.helpBox.CalcHeight(error, 0f)); if (this.controlID == OrderedDictionaryNewEntryManager.ActiveControlID) { newInputHeight = ReorderableListGUI.CalculateListFieldHeight(OrderedDictionaryNewEntryManager.NewEntryListAdaptor, this.ListControl.Flags); } return(TitleHeight + listHeight + NewInputSpacing + newInputHeight + errorOutputHeight + EndSpacing); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { var attribute = (ReorderableListAttribute)this.attribute; var elementsProperty = property.FindPropertyRelative(attribute.ElementsPropertyName); var listAdaptor = new SerializedPropertyWithDropTargetAdaptor(elementsProperty, attribute.DroppableObjectType); float height = 0f; if (label != GUIContent.none) { height += 21f; } height += ReorderableListGUI.CalculateListFieldHeight(listAdaptor, attribute.Flags); return(height); }
/// <inheritdoc/> public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); this.Initialize(property); float newInputHeight = NewInputPlaceholderHeight; float errorOutputHeight = this.errors.Sum(error => EditorStyles.helpBox.CalcHeight(error, 0f)); if (this.controlID == OrderedDictionaryNewEntryManager.ActiveControlID) { newInputHeight = ReorderableListGUI.CalculateListFieldHeight(OrderedDictionaryNewEntryManager.NewEntryListAdaptor, this.ListControl.Flags); } Rect titlePosition = position; titlePosition.height = TitleHeight; ReorderableListGUI.Title(titlePosition, label); Rect listPosition = position; listPosition.yMin += TitleHeight - 1f; listPosition.height -= NewInputSpacing; listPosition.height -= newInputHeight; listPosition.height -= errorOutputHeight; listPosition.height -= EndSpacing; this.DrawDictionaryListControl(listPosition); Rect newInputPosition = position; newInputPosition.yMin = NewInputSpacing + listPosition.yMax; newInputPosition.height = newInputHeight; if (this.controlID == OrderedDictionaryNewEntryManager.ActiveControlID) { DrawDictionaryNewInput(newInputPosition); } else { int activateInputAreaControlID = EditorGUIUtility.GetControlID(FocusType.Passive); switch (Event.current.GetTypeForControl(activateInputAreaControlID)) { case EventType.MouseDown: if (Event.current.button == 0 && newInputPosition.Contains(Event.current.mousePosition)) { OrderedDictionaryNewEntryManager.SetActiveNewEntry(this); this.deferFocusNewInput = true; Event.current.Use(); } break; case EventType.Repaint: var style = new GUIStyle(GUI.skin.box); style.normal.textColor = GUI.skin.button.normal.textColor; style.Draw(newInputPosition, new GUIContent("« Click to add new entry »"), activateInputAreaControlID); break; } } Rect errorOutputPosition = newInputPosition; foreach (var error in this.errors) { errorOutputPosition.yMin = errorOutputPosition.yMax; errorOutputPosition.height = EditorStyles.helpBox.CalcHeight(error, 0f); EditorGUI.HelpBox(errorOutputPosition, error.text, MessageType.Error); } EditorGUI.EndProperty(); }