public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute) { _dictionary = PropertyHelper.GetObject <IEditableDictionary>(property); if (_dictionary == null) { Debug.LogWarningFormat(_invalidTypeWarning, property.propertyPath); } else { _dictionaryControl.Setup(property, _dictionary); if (attribute is DictionaryDisplayAttribute display) { if (display.AssetType != null) { _dictionaryControl.MakeDrawable(ListItemDisplayType.AssetPopup, display.AssetType); } else if (display.ItemDisplay != ListItemDisplayType.Normal) { _dictionaryControl.MakeDrawable(display.ItemDisplay, null); } if (display.AllowAdd) { _dictionaryControl.MakeAddable(_addButton, display.AddLabel == null ? new GUIContent("Add Item") : (display.AddLabel == "" ? GUIContent.none : new GUIContent(display.AddLabel))); } if (display.AllowRemove) { _dictionaryControl.MakeRemovable(_removeButton); } if (display.AllowCollapse) { _dictionaryControl.MakeCollapsable(GetOpenPreference(property)); } if (display.ShowEditButton) { _dictionaryControl.MakeEditable(_editButton); } if (display.EmptyText != null) { _dictionaryControl.MakeEmptyLabel(new GUIContent(display.EmptyText)); } } } }
public override void Setup(SerializedProperty property, FieldInfo fieldInfo) { var attribute = TypeHelper.GetAttribute <DictionaryDisplayAttribute>(fieldInfo); _dictionary = GetObject <IEditableDictionary>(property); if (_dictionary == null) { Debug.LogWarningFormat(_invalidTypeWarning, property.propertyPath); } else { _dictionaryControl.Setup(property, _dictionary); if (attribute != null) { if (attribute.InlineChildren) { _dictionaryControl.MakeDrawableInline(); } if (attribute.AllowAdd) { _dictionaryControl.MakeAddable(_addButton, attribute.AddLabel == null ? new GUIContent("Add Item") : (attribute.AddLabel == "" ? GUIContent.none : new GUIContent(attribute.AddLabel))); } if (attribute.AllowRemove) { _dictionaryControl.MakeRemovable(_removeButton); } if (attribute.AllowCollapse) { _dictionaryControl.MakeCollapsable(GetOpenPreference(property)); } if (attribute.ShowEditButton) { _dictionaryControl.MakeEditable(_editButton); } if (attribute.EmptyText != null) { _dictionaryControl.MakeEmptyLabel(new GUIContent(attribute.EmptyText)); } } } }
public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute) { _dictionary = PropertyHelper.GetObject <IEditableDictionary>(property); _itemDrawer = PropertyHelper.GetNextDrawer(fieldInfo, attribute); if (_dictionary == null) { Debug.LogWarningFormat(_invalidTypeWarning, property.propertyPath); } else { _dictionaryControl.Setup(property, _dictionary); if (attribute is DictionaryDisplayAttribute display) { if (_itemDrawer != null) { _dictionaryControl.MakeDrawable(DrawItem); } if (display.AllowAdd) { _dictionaryControl.MakeAddable(_addButton, display.AddLabel == null ? new GUIContent("Add Item") : (display.AddLabel == string.Empty ? GUIContent.none : new GUIContent(display.AddLabel))); } if (display.AllowRemove) { _dictionaryControl.MakeRemovable(_removeButton); } if (display.AllowCollapse) { _dictionaryControl.MakeCollapsable(); } if (display.EmptyText != null) { _dictionaryControl.MakeEmptyLabel(new GUIContent(display.EmptyText)); } } } }