Ejemplo n.º 1
0
 public ListField(MemberData data, object owner)
     : base(data, owner, false)
 {
 }
Ejemplo n.º 2
0
 public AnimationCurveField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 3
0
 public BoolField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 4
0
 public EnumMaskField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 5
0
 public LayerMaskField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 6
0
 public ColorField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 7
0
        public DictionaryField(MemberData data, object owner)
        {
            _owner          = owner;
            _label          = new GUIContent(data.name, data.description);
            this.memberName = data.member.Name;

            var prop = data.member as PropertyInfo;

            if (prop != null)
            {
                GetKeyValueTypes(prop.PropertyType);
                _dictionary = (IDictionary)prop.GetValue(owner, null);
                if (_dictionary == null)
                {
                    _setter = (dict) =>
                    {
                        _dictionary = dict;
                        prop.SetValue(owner, dict, null);
                        if (_itemCreator != null)
                        {
                            _itemCreator.SetParent(_dictionary);
                        }
                    };
                }
            }
            else
            {
                var field = data.member as FieldInfo;
                if (field != null)
                {
                    GetKeyValueTypes(field.FieldType);
                    _dictionary = (IDictionary)field.GetValue(owner);
                    if (_dictionary == null)
                    {
                        _setter = (dict) =>
                        {
                            _dictionary = dict;
                            field.SetValue(owner, dict);
                            if (_itemCreator != null)
                            {
                                _itemCreator.SetParent(_dictionary);
                            }
                        };
                    }
                }
                else
                {
                    throw new ArgumentException("Invalid reflected member type, only fields and properties are supported.");
                }
            }

            if (_dictionary != null)
            {
                var count = _dictionary.Count;
                _editorItems = new List <EditorItem>(count);
                _itemCreator = new ItemConstructor(_dictionary, _keyType, _valueType);

                foreach (var key in _dictionary.Keys)
                {
                    var item = _itemCreator.Conctruct(key, _dictionary[key]);
                    _editorItems.Add(ReflectMaster.Reflect(item));
                }
            }
            else
            {
                _editorItems = new List <EditorItem>();
            }
        }
Ejemplo n.º 8
0
 public ArrayField(MemberData data, object owner)
     : base(data, owner, true)
 {
 }
Ejemplo n.º 9
0
 public EnumSelectField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 10
0
 public BoundsField(MemberData data, object owner)
     : base(data, owner)
 {
     _center = _curValue.center;
     _size   = _curValue.size;
 }
Ejemplo n.º 11
0
 public StringField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 12
0
 public DoubleField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 13
0
 public AIReferenceField(MemberData data, object owner)
     : base(data, owner)
 {
     UpdateName();
 }
Ejemplo n.º 14
0
 public Vector3Field(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 15
0
 public ShortField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 16
0
 public FloatField(MemberData data, object owner)
     : base(data, owner)
 {
 }
Ejemplo n.º 17
0
        protected ListFieldBase(MemberData data, object owner, bool requiresSetter)
        {
            _owner          = owner;
            _label          = new GUIContent(data.name, data.description);
            this.memberName = data.member.Name;

            var prop = data.member as PropertyInfo;

            if (prop != null)
            {
                _reorderable = !prop.IsDefined <NotReorderableAttribute>(true);
                _itemType    = GetItemType(prop.PropertyType);
                _list        = (IList)prop.GetValue(owner, null);
                if (_list == null || requiresSetter)
                {
                    _setter = (list) =>
                    {
                        _list = list;
                        prop.SetValue(owner, list, null);
                        if (_simpleItemCreator != null)
                        {
                            _simpleItemCreator.SetParent(_list);
                        }
                    };
                }
            }
            else
            {
                var field = data.member as FieldInfo;
                if (field != null)
                {
                    _reorderable = !field.IsDefined <NotReorderableAttribute>(true);
                    _itemType    = GetItemType(field.FieldType);
                    _list        = (IList)field.GetValue(owner);
                    if (_list == null || requiresSetter)
                    {
                        _setter = (list) =>
                        {
                            _list = list;
                            field.SetValue(owner, list);
                            if (_simpleItemCreator != null)
                            {
                                _simpleItemCreator.SetParent(_list);
                            }
                        };
                    }
                }
                else
                {
                    throw new ArgumentException("Invalid reflected member type, only fields and properties are supported.");
                }
            }

            _isSimpleType = SerializationMaster.ConverterExists(_itemType) || SerializationMaster.StagerExists(_itemType);

            if (_list != null)
            {
                var count = _list.Count;
                _editorItems = new List <EditorItem>(count);

                if (_isSimpleType)
                {
                    _simpleItemCreator = new SimpleItemConstructor(_list, _itemType);

                    for (int i = 0; i < count; i++)
                    {
                        var item = _simpleItemCreator.Conctruct(i, _list[i]);
                        _editorItems.Add(ReflectMaster.Reflect(item));
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        _editorItems.Add(ReflectMaster.Reflect(_list[i]));
                    }
                }
            }
            else
            {
                _editorItems = new List <EditorItem>();
            }
        }