/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <TList> entry, GUIContent label) { var property = entry.Property; int minCount = int.MaxValue; int maxCount = 0; PropertyContext <bool> isVisible; if (entry.Context.Get(this, "is_visible", out isVisible)) { isVisible.Value = GeneralDrawerConfig.Instance.OpenListsByDefault; } for (int i = 0; i < entry.ValueCount; i++) { if (entry.Values[i].Count > maxCount) { maxCount = entry.Values[i].Count; } if (entry.Values[i].Count < minCount) { minCount = entry.Values[i].Count; } } AllEditorGUI.BeginHorizontalToolbar(); isVisible.Value = AllEditorGUI.Foldout(isVisible.Value, GUIHelper.TempContent("SyncList " + label.text + " [" + typeof(TList).Name + "]")); EditorGUILayout.LabelField(GUIHelper.TempContent(minCount == maxCount ? (minCount == 0 ? "Empty" : minCount + " items") : minCount + " (" + maxCount + ") items"), SirenixGUIStyles.RightAlignedGreyMiniLabel); AllEditorGUI.EndHorizontalToolbar(); if (AllEditorGUI.BeginFadeGroup(isVisible, isVisible.Value)) { GUIHelper.PushGUIEnabled(false); AllEditorGUI.BeginVerticalList(); { var elementLabel = new GUIContent(); for (int i = 0; i < maxCount; i++) { AllEditorGUI.BeginListItem(); elementLabel.text = "Item " + i; if (i < minCount) { InspectorUtilities.DrawProperty(property.Children[i], elementLabel); } else { EditorGUILayout.LabelField(elementLabel, "—"); } AllEditorGUI.EndListItem(); } } AllEditorGUI.EndVerticalList(); GUIHelper.PopGUIEnabled(); } AllEditorGUI.EndFadeGroup(); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label) { if (entry.ValueState == PropertyValueState.Reference) { var isToggled = entry.Context.GetPersistent(this, "is_Toggled", false); var targetProp = entry.Property.Tree.GetPropertyAtPath(entry.TargetReferencePath); AllEditorGUI.BeginBox(); AllEditorGUI.BeginBoxHeader(); EditorGUILayout.BeginHorizontal(); isToggled.Value = label != null?AllEditorGUI.Foldout(isToggled.Value, label) : AllEditorGUI.Foldout(isToggled.Value, GUIHelper.TempContent("")); if (targetProp.Parent == null) { EditorGUILayout.LabelField("Reference to " + targetProp.Path, SirenixGUIStyles.RightAlignedGreyMiniLabel); } else { EditorGUILayout.LabelField("Reference to " + targetProp.Path, SirenixGUIStyles.RightAlignedGreyMiniLabel); } EditorGUILayout.EndHorizontal(); AllEditorGUI.EndBoxHeader(); if (AllEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(entry.Property, this), isToggled.Value)) { //EditorGUI.indentLevel++; //GUIHelper.PushGUIEnabled(true); var isInReference = targetProp.Context.GetGlobal("is_in_reference", false); bool previous = isInReference.Value; isInReference.Value = true; InspectorUtilities.DrawProperty(targetProp); isInReference.Value = previous; //GUIHelper.PopGUIEnabled(); //EditorGUI.indentLevel--; } AllEditorGUI.EndFadeGroup(); AllEditorGUI.EndBox(); } else { this.CallNextDrawer(entry.Property, label); } }
/// <summary> /// Not yet documented. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <GUIStyleState> entry, GUIContent label) { var property = entry.Property; var isVisible = property.Context.Get(this, "isVisible", AllEditorGUI.ExpandFoldoutByDefault); isVisible.Value = AllEditorGUI.Foldout(isVisible.Value, label ?? GUIContent.none); if (AllEditorGUI.BeginFadeGroup(isVisible, isVisible.Value)) { EditorGUI.indentLevel++; entry.SmartValue.background = (Texture2D)SirenixEditorFields.UnityObjectField(label, entry.SmartValue.background, typeof(Texture2D), true); entry.SmartValue.textColor = EditorGUILayout.ColorField(label ?? GUIContent.none, entry.SmartValue.textColor); EditorGUI.indentLevel--; } AllEditorGUI.EndFadeGroup(); }
private static void DrawObjectField(IPropertyValueEntry <T> entry, GUIContent label, ref bool isToggled, bool showToggle = true) { var prev = EditorGUI.showMixedValue; if (entry.ValueState == PropertyValueState.ReferenceValueConflict) { EditorGUI.showMixedValue = true; } object newValue; GUI.changed = false; if (showToggle == false) { #pragma warning disable 0618 // Type or member is obsolete newValue = AllEditorGUI.ObjectField(entry, entry.BaseValueType, label, entry.SmartValue, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); #pragma warning restore 0618 // Type or member is obsolete } else if (label == null) { EditorGUI.indentLevel++; #pragma warning disable 0618 // Type or member is obsolete newValue = AllEditorGUI.ObjectField(entry, entry.BaseValueType, label, entry.SmartValue, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); #pragma warning restore 0618 // Type or member is obsolete EditorGUI.indentLevel--; } else { newValue = SirenixEditorFields.PolymorphicObjectField(GUIHelper.TempContent(" " + label.text, label.tooltip), entry.SmartValue, entry.BaseValueType, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); } if (GUI.changed) { //entry.WeakSmartValue = newValue; entry.Property.Tree.DelayActionUntilRepaint(() => entry.WeakSmartValue = newValue); } if (showToggle) { isToggled = AllEditorGUI.Foldout(GUILayoutUtility.GetLastRect(), isToggled, GUIContent.none); } EditorGUI.showMixedValue = prev; }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <Rect> entry, GUIContent label) { if (label == null) { this.DrawValues(entry); } else { var isVisible = entry.Property.Context.GetPersistent <bool>(this, "IsVisible", GeneralDrawerConfig.Instance.ExpandFoldoutByDefault); isVisible.Value = AllEditorGUI.Foldout(isVisible.Value, label); if (AllEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(entry, this), isVisible.Value)) { EditorGUI.indentLevel++; this.DrawValues(entry); EditorGUI.indentLevel--; } AllEditorGUI.EndFadeGroup(); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyGroupLayout(InspectorProperty property, FoldoutGroupAttribute attribute, GUIContent label) { var context = property.Context.Get <FoldoutGroupContext>(this, "FoldoutGroupContext", (FoldoutGroupContext)null); if (context.Value == null) { context.Value = new FoldoutGroupContext() { IsVisible = property.Context.GetPersistent <bool>(this, "IsVisible", attribute.HasDefinedExpanded ? attribute.Expanded : AllEditorGUI.ExpandFoldoutByDefault), TitleHelper = new StringMemberHelper(property.ParentType, attribute.GroupName) }; } if (context.Value.TitleHelper.ErrorMessage != null) { AllEditorGUI.ErrorMessageBox(context.Value.TitleHelper.ErrorMessage); } AllEditorGUI.BeginBox(); { AllEditorGUI.BeginBoxHeader(); var content = GUIHelper.TempContent(context.Value.TitleHelper.GetString(property)); var rect = GUILayoutUtility.GetRect(content, SirenixGUIStyles.Label); context.Value.IsVisible.Value = AllEditorGUI.Foldout(rect, context.Value.IsVisible.Value, content); AllEditorGUI.EndBoxHeader(); if (AllEditorGUI.BeginFadeGroup(context, context.Value.IsVisible.Value)) { for (int i = 0; i < property.Children.Count; i++) { InspectorUtilities.DrawProperty(property.Children[i]); } } AllEditorGUI.EndFadeGroup(); } AllEditorGUI.EndBox(); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyImplementation(InspectorProperty property, GUIContent label) { if (label == null) { AllEditorGUI.BeginIndentedVertical(); for (int i = 0; i < property.Children.Count; i++) { InspectorUtilities.DrawProperty(property.Children[i]); } AllEditorGUI.EndIndentedVertical(); } else { Context context; if (property.Context.Get <Context>(this, "context", out context)) { context.IsVisisble = property.Context.GetPersistent(this, "IsVisible", AllEditorGUI.ExpandFoldoutByDefault); context.IsInlineProperty = property.ValueEntry.TypeOfValue.GetAttribute <InlinePropertyAttribute>() ?? property.Info.GetAttribute <InlinePropertyAttribute>(); } if (context.IsInlineProperty != null) { var outerRect = EditorGUILayout.BeginHorizontal(); { if (Event.current.type == EventType.Repaint) { outerRect.y += 1; EditorGUI.PrefixLabel(outerRect, label); } GUILayout.Space(EditorGUIUtility.labelWidth); GUILayout.BeginVertical(); { if (context.IsInlineProperty.LabelWidth > 0) { GUIHelper.PushLabelWidth(context.IsInlineProperty.LabelWidth); } GUIHelper.PushIndentLevel(0); for (int i = 0; i < property.Children.Count; i++) { InspectorUtilities.DrawProperty(property.Children[i]); } GUIHelper.PopIndentLevel(); if (context.IsInlineProperty.LabelWidth > 0) { GUIHelper.PopLabelWidth(); } } GUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); } else { context.IsVisisble.Value = AllEditorGUI.Foldout(context.IsVisisble.Value, label); if (AllEditorGUI.BeginFadeGroup(context, context.IsVisisble.Value)) { EditorGUI.indentLevel++; for (int i = 0; i < property.Children.Count; i++) { InspectorUtilities.DrawProperty(property.Children[i]); } EditorGUI.indentLevel--; } AllEditorGUI.EndFadeGroup(); } } }
private void DrawToolbar(ListDrawerConfigInfo info) { AllEditorGUI.BeginHorizontalToolbar(); { // Label if (DragAndDropManager.IsDragInProgress && info.DropZone.IsAccepted == false) { GUIHelper.PushGUIEnabled(false); } if (info.property.ValueEntry.ListLengthChangedFromPrefab) { GUIHelper.PushIsBoldLabel(true); } if (info.listConfig.HideFoldoutWhileEmpty && info.IsEmpty || info.CustomListDrawerOptions.Expanded) { GUILayout.Label(info.label, GUILayoutOptions.ExpandWidth(false)); } else { info.Toggled.Value = AllEditorGUI.Foldout(info.Toggled.Value, info.label ?? GUIContent.none); } if (info.property.ValueEntry.ListLengthChangedFromPrefab) { GUIHelper.PopIsBoldLabel(); } if (info.CustomListDrawerOptions.Expanded) { info.Toggled.Value = true; } if (DragAndDropManager.IsDragInProgress && info.DropZone.IsAccepted == false) { GUIHelper.PopGUIEnabled(); } GUILayout.FlexibleSpace(); // Item Count if (info.CustomListDrawerOptions.ShowItemCountHasValue ? info.CustomListDrawerOptions.ShowItemCount : info.listConfig.ShowItemCount) { if (info.property.ValueEntry.ValueState == PropertyValueState.CollectionLengthConflict) { int maxLength = 0; for (int i = 0; i < info.property.ValueEntry.ValueCount; i++) { maxLength = Math.Max(maxLength, (info.property.ValueEntry.WeakValues[i] as IList <TElement>).Count); } GUILayout.Label(info.Count + " / " + maxLength + " items", EditorStyles.centeredGreyMiniLabel); } else { GUILayout.Label(info.IsEmpty ? "Empty" : info.Count + " items", EditorStyles.centeredGreyMiniLabel); } } bool paging = info.CustomListDrawerOptions.PagingHasValue ? info.CustomListDrawerOptions.ShowPaging : true; bool hidePaging = info.listConfig.HidePagingWhileCollapsed && info.Toggled.Value == false || info.listConfig.HidePagingWhileOnlyOnePage && info.Count <= info.NumberOfItemsPerPage; int numberOfItemsPrPage = Math.Max(1, info.NumberOfItemsPerPage); int numberOfPages = Mathf.CeilToInt(info.Count / (float)numberOfItemsPrPage); int pageIndex = info.Count == 0 ? 0 : (info.StartIndex / numberOfItemsPrPage) % info.Count; // Paging if (paging) { bool disablePaging = paging && !hidePaging && (DragAndDropManager.IsDragInProgress || info.ShowAllWhilePageing || info.Toggled.Value == false); if (disablePaging) { GUIHelper.PushGUIEnabled(false); } if (!hidePaging) { if (pageIndex == 0) { GUIHelper.PushGUIEnabled(false); } if (AllEditorGUI.ToolbarButton(EditorIcons.TriangleLeft, true)) { if (Event.current.button == 0) { info.StartIndex -= numberOfItemsPrPage; } else { info.StartIndex = 0; } } if (pageIndex == 0) { GUIHelper.PopGUIEnabled(); } var userPageIndex = EditorGUILayout.IntField((numberOfPages == 0 ? 0 : (pageIndex + 1)), GUILayoutOptions.Width(10 + numberOfPages.ToString(CultureInfo.InvariantCulture).Length * 10)) - 1; if (pageIndex != userPageIndex) { info.StartIndex = userPageIndex * numberOfItemsPrPage; } GUILayout.Label("/ " + numberOfPages); if (pageIndex == numberOfPages - 1) { GUIHelper.PushGUIEnabled(false); } if (AllEditorGUI.ToolbarButton(EditorIcons.TriangleRight, true)) { if (Event.current.button == 0) { info.StartIndex += numberOfItemsPrPage; } else { info.StartIndex = numberOfItemsPrPage * numberOfPages; } } if (pageIndex == numberOfPages - 1) { GUIHelper.PopGUIEnabled(); } } pageIndex = info.Count == 0 ? 0 : (info.StartIndex / numberOfItemsPrPage) % info.Count; var newStartIndex = Mathf.Clamp(pageIndex * numberOfItemsPrPage, 0, Mathf.Max(0, info.Count - 1)); if (newStartIndex != info.StartIndex) { info.StartIndex = newStartIndex; var newPageIndex = info.Count == 0 ? 0 : (info.StartIndex / numberOfItemsPrPage) % info.Count; if (pageIndex != newPageIndex) { pageIndex = newPageIndex; info.StartIndex = Mathf.Clamp(pageIndex * numberOfItemsPrPage, 0, Mathf.Max(0, info.Count - 1)); } } info.EndIndex = Mathf.Min(info.StartIndex + numberOfItemsPrPage, info.Count); if (disablePaging) { GUIHelper.PopGUIEnabled(); } } else { info.StartIndex = 0; info.EndIndex = info.Count; } if (paging && hidePaging == false && info.listConfig.ShowExpandButton) { if (AllEditorGUI.ToolbarButton(info.ShowAllWhilePageing ? EditorIcons.TriangleUp : EditorIcons.TriangleDown, true)) { info.ShowAllWhilePageing = !info.ShowAllWhilePageing; } } // Add Button if (info.IsReadOnly == false && !info.CustomListDrawerOptions.HideAddButton) { info.ObjectPicker = ObjectPicker <TElement> .GetObjectPicker(info); if (AllEditorGUI.ToolbarButton(EditorIcons.Plus)) { if (info.CustomListDrawerOptions.AlwaysAddDefaultValue) { var objs = new object[info.ListValueChanger.ValueCount]; if (info.property.ValueEntry.SerializationBackend == SerializationBackend.Unity) { for (int i = 0; i < objs.Length; i++) { objs[i] = UnitySerializationUtility.CreateDefaultUnityInitializedObject(typeof(TElement)); } } else { for (int i = 0; i < objs.Length; i++) { objs[i] = default(TElement); } } info.ListValueChanger.AddListElement(objs, "Add default value"); } else if (typeof(TElement).InheritsFrom <UnityEngine.Object>() && Event.current.modifiers == EventModifiers.Control) { info.ListValueChanger.AddListElement(new object[info.ListValueChanger.ValueCount], "Add Unity Null Value"); } else { info.ObjectPicker.ShowObjectPicker( info.property.Info.GetAttribute <AssetsOnlyAttribute>() == null, GUIHelper.GetCurrentLayoutRect(), info.property.ValueEntry.SerializationBackend == SerializationBackend.Unity); } } info.JumpToNextPageOnAdd = paging && (info.Count % numberOfItemsPrPage == 0) && (pageIndex + 1 == numberOfPages); } if (info.OnTitleBarGUI != null) { info.OnTitleBarGUI(info.property.ParentValues[0]); } } AllEditorGUI.EndHorizontalToolbar(); }
public void DrawItem() { bool hasLabel = this.labelName != null && (this.matchesSearchTerm || this.window.hasSearchTerm == false); if (hasLabel) { bool isSelected = false, isChosen = false; if (this.ChildNodes != null) { if (this.window.hideFoldoutLabels == false) { AllEditorGUI.BeginMenuListItem(out isSelected, out isChosen, this.ForceSetSelected); { if (this.matchesSearchTerm) { AllEditorGUI.Foldout(true, this.label); } else { this.IsVisible = AllEditorGUI.Foldout(this.IsVisible, this.label); } } AllEditorGUI.EndMenuListItem(); } } else { AllEditorGUI.BeginMenuListItem(out isSelected, out isChosen, this.ForceSetSelected); { //if (this.drawHasNoEmptyConstructor) //{ // GUIHelper.PushGUIEnabled(false); //} // Properbly a type if (this.isTypeNode && this.Type == typeof(NullType)) { EditorGUILayout.LabelField(this.label, SirenixGUIStyles.LeftAlignedGreyMiniLabel); } else { EditorGUILayout.LabelField(this.label); } //if (this.drawHasNoEmptyConstructor) //{ // GUIHelper.PopGUIEnabled(); //} if (this.drawHasNoEmptyConstructor) { var rect = GUILayoutUtility.GetLastRect(); rect.width -= 16; EditorIcons.AlertTriangle.Draw(new Rect(rect.xMax, rect.yMin, 16, 16)); GUI.Label(rect, this.hasNoEmptyConstructorLabel, SirenixGUIStyles.RightAlignedGreyMiniLabel); //isChosen = false; } //var rect = GUILayoutUtility.GetLastRect(); //if (this.isTypeNode && this.showNotSerializableLabel) //{ // GUI.Label(rect, isNotSerializableLabel, isSelected ? SirenixGUIStyles.RightAlignedWhiteMiniLabel : SirenixGUIStyles.RightAlignedGreyMiniLabel); //} } AllEditorGUI.EndMenuListItem(); } if (isSelected && Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.RightArrow) { this.IsVisible = true; } else if (Event.current.keyCode == KeyCode.LeftArrow) { this.IsVisible = false; } else if (Event.current.keyCode == KeyCode.Return) { isChosen = true; } } if (isChosen) { this.IsVisible = !this.IsVisible; if (this.isTypeNode) { this.window.chosenType = this.Type; } } this.ForceSetSelected = false; } if (this.labelName == null) { this.IsVisible = true; } if (this.ChildNodes != null) { if (this.matchesSearchTerm || AllEditorGUI.BeginFadeGroup(this, this.IsVisible)) { if (hasLabel && !this.window.hideFoldoutLabels) { EditorGUI.indentLevel++; } for (int i = 0; i < this.ChildNodes.Count; i++) { this.ChildNodes[i].DrawItem(); } if (hasLabel && !this.window.hideFoldoutLabels) { EditorGUI.indentLevel--; } } if (this.matchesSearchTerm == false) { AllEditorGUI.EndFadeGroup(); } } }
private void DrawElements(IPropertyValueEntry <TDictionary> entry, GUIContent label, Context context) { for (int i = context.Paging.StartIndex; i < context.Paging.EndIndex; i++) { var keyValuePairProperty = entry.Property.Children[i]; var keyValuePairEntry = (PropertyDictionaryElementValueEntry <TDictionary, TKey, TValue>)keyValuePairProperty.BaseValueEntry; Rect rect = AllEditorGUI.BeginListItem(false, context.ListItemStyle); { if (context.AttrSettings.DisplayMode != DictionaryDisplayOptions.OneLine) { bool defaultExpanded; switch (context.AttrSettings.DisplayMode) { case DictionaryDisplayOptions.CollapsedFoldout: defaultExpanded = false; break; case DictionaryDisplayOptions.ExpandedFoldout: defaultExpanded = true; break; default: defaultExpanded = AllEditorGUI.ExpandFoldoutByDefault; break; } var isExpanded = keyValuePairProperty.Context.Get(this, "Expanded", defaultExpanded); AllEditorGUI.BeginBox(); AllEditorGUI.BeginBoxHeader(); { if (keyValuePairEntry.HasTempInvalidKey) { GUIHelper.PushColor(Color.red); } var btnRect = GUIHelper.GetCurrentLayoutRect().AlignLeft(HeaderMargin.margin.left); btnRect.y += 1; GUILayout.BeginVertical(HeaderMargin); GUIHelper.PushIsDrawingDictionaryKey(true); GUIHelper.PushLabelWidth(10); InspectorUtilities.DrawProperty(keyValuePairProperty.Children[0], null); GUIHelper.PopLabelWidth(); GUIHelper.PopIsDrawingDictionaryKey(); GUILayout.EndVertical(); if (keyValuePairEntry.HasTempInvalidKey) { GUIHelper.PopColor(); } isExpanded.Value = AllEditorGUI.Foldout(btnRect, isExpanded.Value, GUIHelper.TempContent("Key")); } AllEditorGUI.EndBoxHeader(); if (AllEditorGUI.BeginFadeGroup(isExpanded, isExpanded.Value)) { InspectorUtilities.DrawProperty(keyValuePairProperty.Children[1], null); } AllEditorGUI.EndFadeGroup(); AllEditorGUI.EndBox(); } else { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayoutOptions.Width(context.KeyWidthOffset)); { var keyProperty = keyValuePairProperty.Children[0]; if (keyValuePairEntry.HasTempInvalidKey) { GUIHelper.PushColor(Color.red); } if (context.AttrSettings.IsReadOnly) { GUIHelper.PushGUIEnabled(false); } GUIHelper.PushIsDrawingDictionaryKey(true); GUIHelper.PushLabelWidth(10); InspectorUtilities.DrawProperty(keyProperty, null); GUIHelper.PopLabelWidth(); GUIHelper.PopIsDrawingDictionaryKey(); if (context.AttrSettings.IsReadOnly) { GUIHelper.PopGUIEnabled(); } if (keyValuePairEntry.HasTempInvalidKey) { GUIHelper.PopColor(); } } GUILayout.EndVertical(); GUILayout.BeginVertical(OneLineMargin); { var valueEntry = keyValuePairProperty.Children[1]; var tmp = GUIHelper.ActualLabelWidth; EditorGUIUtility.labelWidth = 150; InspectorUtilities.DrawProperty(valueEntry, null); EditorGUIUtility.labelWidth = tmp; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } if (entry.IsEditable && !context.AttrSettings.IsReadOnly && AllEditorGUI.IconButton(new Rect(rect.xMax - 24 + 5, rect.y + 2 + ((int)rect.height - 23) / 2, 14, 14), EditorIcons.X)) { context.DictionaryHandler.Remove(context.DictionaryHandler.GetKey(0, i)); EditorApplication.delayCall += () => context.NewKewIsValid = null; GUIHelper.RequestRepaint(); } } AllEditorGUI.EndListItem(); } if (context.Paging.IsOnLastPage && entry.ValueState == PropertyValueState.CollectionLengthConflict) { AllEditorGUI.BeginListItem(false); GUILayout.Label(GUIHelper.TempContent("------"), EditorStyles.centeredGreyMiniLabel); AllEditorGUI.EndListItem(); } }
private void DrawToolbar(IPropertyValueEntry <TDictionary> entry, Context context) { AllEditorGUI.BeginHorizontalToolbar(); { if (entry.ListLengthChangedFromPrefab) { GUIHelper.PushIsBoldLabel(true); } if (context.Config.HideFoldoutWhileEmpty && context.Paging.ElementCount == 0) { GUILayout.Label(context.Label, GUILayoutOptions.ExpandWidth(false)); } else { context.Toggled.Value = AllEditorGUI.Foldout(context.Toggled.Value, context.Label); } if (entry.ListLengthChangedFromPrefab) { GUIHelper.PopIsBoldLabel(); } GUILayout.FlexibleSpace(); // Item Count if (context.Config.ShowItemCount) { if (entry.ValueState == PropertyValueState.CollectionLengthConflict) { int min = entry.Values.Min(x => x.Count); int max = entry.Values.Max(x => x.Count); GUILayout.Label(min + " / " + max + " items", EditorStyles.centeredGreyMiniLabel); } else { GUILayout.Label(context.Paging.ElementCount == 0 ? "Empty" : context.Paging.ElementCount + " items", EditorStyles.centeredGreyMiniLabel); } } bool hidePaging = context.Config.HidePagingWhileCollapsed && context.Toggled.Value == false || context.Config.HidePagingWhileOnlyOnePage && context.Paging.PageCount == 1; if (!hidePaging) { var wasEnabled = GUI.enabled; bool pagingIsRelevant = context.Paging.IsEnabled && context.Paging.PageCount != 1; GUI.enabled = wasEnabled && pagingIsRelevant && !context.Paging.IsOnFirstPage; if (AllEditorGUI.ToolbarButton(EditorIcons.ArrowLeft, true)) { if (Event.current.button == 0) { context.Paging.CurrentPage--; } else { context.Paging.CurrentPage = 0; } } GUI.enabled = wasEnabled && pagingIsRelevant; var width = GUILayoutOptions.Width(10 + context.Paging.PageCount.ToString().Length * 10); context.Paging.CurrentPage = EditorGUILayout.IntField(context.Paging.CurrentPage + 1, width) - 1; GUILayout.Label(GUIHelper.TempContent("/ " + context.Paging.PageCount)); GUI.enabled = wasEnabled && pagingIsRelevant && !context.Paging.IsOnLastPage; if (AllEditorGUI.ToolbarButton(EditorIcons.ArrowRight, true)) { if (Event.current.button == 0) { context.Paging.CurrentPage++; } else { context.Paging.CurrentPage = context.Paging.PageCount - 1; } } GUI.enabled = wasEnabled && context.Paging.PageCount != 1; if (context.Config.ShowExpandButton) { if (AllEditorGUI.ToolbarButton(context.Paging.IsEnabled ? EditorIcons.ArrowDown : EditorIcons.ArrowUp, true)) { context.Paging.IsEnabled = !context.Paging.IsEnabled; } } GUI.enabled = wasEnabled; } if (!context.DisableAddKey && context.AttrSettings.IsReadOnly != true) { if (AllEditorGUI.ToolbarButton(EditorIcons.Plus)) { context.ShowAddKeyGUI = !context.ShowAddKeyGUI; } } } AllEditorGUI.EndHorizontalToolbar(); }