Exemple #1
0
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
        {
            SetupDrawerDictionary();

            var nextAttribute = attribute;
            var found         = false;

            while (!found)
            {
                var attributes      = fieldInfo.GetCustomAttributes <PropertyAttribute>(true);
                var drawerAttribute = attributes.LastOrDefault(next => next.order < nextAttribute.order && !_ignoredTypes.Contains(next.GetType()));

                var typeToDraw = drawerAttribute == null ? fieldInfo.FieldType : drawerAttribute.GetType();

                if (_drawerLookup.TryGetValue(typeToDraw, out var drawer))
                {
                    if (TypeHelper.IsCreatableAs <DecoratorDrawer>(drawer))
                    {
                        nextAttribute = drawerAttribute;
                        continue;
                    }

                    _nextDrawer = Activator.CreateInstance(drawer) as PropertyDrawer;
                    _fieldInfoField.SetValue(_nextDrawer, fieldInfo);
                    _attributeField.SetValue(_nextDrawer, drawerAttribute);
                }

                found = true;
            }
        }
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
        {
            _property   = property.FindPropertyRelative("_items");
            _itemDrawer = PropertyHelper.GetNextDrawer(fieldInfo, attribute);

            if (_property == null || !_property.isArray)
            {
                Debug.LogWarningFormat(_invalidTypeWarning, property.propertyPath);
                _property = null;
            }
            else
            {
                _listControl.Setup(_property);

                if (attribute is ListDisplayAttribute display)
                {
                    if (_itemDrawer != null)
                    {
                        _listControl.MakeDrawable(DrawItem);
                        _listControl.MakeCustomHeight(GetItemHeight);
                    }

                    if (display.AllowAdd)
                    {
                        _listControl.MakeAddable(_addButton);
                    }

                    if (display.AllowRemove)
                    {
                        _listControl.MakeRemovable(_removeButton);
                    }

                    if (display.AllowReorder)
                    {
                        _listControl.MakeReorderable();
                    }

                    if (display.AllowCollapse)
                    {
                        _listControl.MakeCollapsable();
                    }

                    if (display.EmptyText != null)
                    {
                        _listControl.MakeEmptyLabel(new GUIContent(display.EmptyText));
                    }
                }
            }
        }
Exemple #3
0
        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));
                    }
                }
            }
        }
Exemple #4
0
 public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
 {
     _nextDrawer = PropertyHelper.GetNextDrawer(fieldInfo, attribute);
 }