Exemplo n.º 1
0
        protected ReflectedProperty(ReflectedProperty parent, string name, Type declaredType, object value)
        {
            this.parent        = parent;
            this.name          = name;
            this.originalValue = value;
            this.actualValue   = value;
            this.declaredType  = declaredType;
            this.actualType    = value == null ? declaredType : value.GetType();

            this.label           = StringUtil.SplitAndTitlize(name);
            this.children        = new List <ReflectedProperty>(4);
            this.guiContent      = new GUIContent(label);
            this.changedChildren = new List <ReflectedProperty>();
            this.isHidden        = false;
            this.isDirty         = false;
            if (parent != null)
            {
                fieldInfo = parent.Type.GetField(name, BindFlags);
                object[] attrs = fieldInfo?.GetCustomAttributes(false);
                attributes = new List <Attribute>();
                if (attrs != null)
                {
                    for (int i = 0; i < attrs.Length; i++)
                    {
                        attributes.Add((Attribute)attrs[i]);
                    }
                }
                isHidden   = HasAttribute <HideInInspector>();
                isExpanded = HasAttribute <DefaultExpanded>();
            }
            this.drawer = EditorReflector.CreateReflectedPropertyDrawer(this);
        }
Exemplo n.º 2
0
        public static ReflectedPropertyDrawer CreateReflectedPropertyDrawer(ReflectedProperty property)
        {
            Type drawerType = GetPropertyDrawerForReflectedProperty(property);

            Debug.Assert(drawerType != null, "drawerType != null");
            ReflectedPropertyDrawer drawer = MakeInstance(drawerType) as ReflectedPropertyDrawer;

            Debug.Assert(drawer != null, "drawer != null");
            drawer.SetProperty(property);
            return(drawer);
        }
Exemplo n.º 3
0
 protected void Destroy()
 {
     DestroyChildren();
     this.drawer          = null;
     this.actualValue     = null;
     this.children        = null;
     this.parent          = null;
     this.attributes      = null;
     this.guiContent      = null;
     this.changedChildren = null;
     this.fieldInfo       = null;
 }
Exemplo n.º 4
0
        protected virtual void SetValue(object value)
        {
            Type previousType = actualType;

            if (value == null)
            {
                actualType  = declaredType;
                actualValue = EditorReflector.GetDefaultForType(declaredType);
            }
            else
            {
                actualType  = value.GetType();
                actualValue = value;
            }
            if (actualType != previousType)
            {
                this.drawer = EditorReflector.CreateReflectedPropertyDrawer(this);
            }
        }
Exemplo n.º 5
0
 protected void UpdateDrawer()
 {
     drawer.OnDestroy();
     drawer = EditorReflector.CreateReflectedPropertyDrawer(this);
 }