private void OnDisable()
        {
            PropertyMetaDatabase.ClearCache();
            PropertyDrawerDatabase.ClearCache();
            PropertyGrouperDatabase.ClearCache();
            PropertyValidatorDatabase.ClearCache();
            PropertyDrawConditionDatabase.ClearCache();

            MethodDrawerDatabase.ClearCache();
        }
Пример #2
0
 protected virtual void OnDisable()
 {
     PropertyDrawerDatabase.ClearCache();
     this.fields                   = null;
     this.fields                   = null;
     this.groupedFields            = null;
     this.groupedFieldsByGroupName = null;
     this.nonSerializedFields      = null;
     this.nativeProperties         = null;
     this.methods                  = null;
 }
Пример #3
0
 private PropertyDrawer GetPropertyDrawerForField(FieldInfo field)
 {
     DrawerAttribute[] drawerAttributes = (DrawerAttribute[])field.GetCustomAttributes(typeof(DrawerAttribute), true);
     if (drawerAttributes.Length > 0)
     {
         PropertyDrawer drawer = PropertyDrawerDatabase.GetDrawerForAttribute(drawerAttributes[0].GetType());
         return(drawer);
     }
     else
     {
         return(null);
     }
 }
Пример #4
0
 protected PropertyDrawer GetPropertyDrawerForField(FieldInfo field)
 {
     DrawerAttribute[] drawerAttributes = (DrawerAttribute[])field.GetCustomAttributes(typeof(DrawerAttribute), true);
     if (drawerAttributes.Length > 0)
     {
         var            attr   = drawerAttributes[0].GetType();
         PropertyDrawer drawer = PropertyDrawerDatabase.GetDrawerForAttribute(attr);
         if (drawer == null)
         {
             Debug.LogError($"DrawerAttribute: {attr.GetType().Name} is defined, but coresponding Drawer is missing. [Update Attribute Database] may fixed this.");
             return(null);
         }
         return(drawer.Clone());
     }
     else
     {
         return(null);
     }
 }
Пример #5
0
 private void OnDisable()
 {
     PropertyDrawerDatabase.ClearCache();
 }
Пример #6
0
        public override void OnInspectorGUI()
        {
            if (this.useDefaultInspector)
            {
                this.DrawDefaultInspector();
            }
            else
            {
                this.serializedObject.Update();

                if (this.script != null)
                {
                    GUI.enabled = false;
                    EditorGUILayout.PropertyField(this.script);
                    GUI.enabled = true;
                }

                // Draw fields
                HashSet <string> drawnGroups = new HashSet <string>();
                foreach (var field in this.fields)
                {
                    if (this.groupedFields.Contains(field))
                    {
                        // Draw grouped fields
                        string groupName = (field.GetCustomAttributes(typeof(GroupAttribute), true)[0] as GroupAttribute).Name;
                        if (!drawnGroups.Contains(groupName))
                        {
                            drawnGroups.Add(groupName);

                            PropertyGrouper grouper = this.GetPropertyGrouperForField(field);
                            if (grouper != null)
                            {
                                grouper.BeginGroup(groupName);

                                this.ValidateAndDrawFields(this.groupedFieldsByGroupName[groupName]);

                                grouper.EndGroup();
                            }
                            else
                            {
                                this.ValidateAndDrawFields(this.groupedFieldsByGroupName[groupName]);
                            }
                        }
                    }
                    else
                    {
                        // Draw non-grouped field
                        this.ValidateAndDrawField(field);
                    }
                }

                this.serializedObject.ApplyModifiedProperties();
            }

            // Draw non-serialized fields
            foreach (var field in this.nonSerializedFields)
            {
                DrawerAttribute drawerAttribute = (DrawerAttribute)field.GetCustomAttributes(typeof(DrawerAttribute), true)[0];
                FieldDrawer     drawer          = FieldDrawerDatabase.GetDrawerForAttribute(drawerAttribute.GetType());
                if (drawer != null)
                {
                    drawer.DrawField(this.target, field);
                }
            }

            // Draw native properties
            foreach (var property in this.nativeProperties)
            {
                DrawerAttribute      drawerAttribute = (DrawerAttribute)property.GetCustomAttributes(typeof(DrawerAttribute), true)[0];
                NativePropertyDrawer drawer          = NativePropertyDrawerDatabase.GetDrawerForAttribute(drawerAttribute.GetType());
                if (drawer != null)
                {
                    drawer.DrawNativeProperty(this.target, property);
                }
            }

            // Draw methods
            foreach (var method in this.methods)
            {
                DrawerAttribute drawerAttribute = (DrawerAttribute)method.GetCustomAttributes(typeof(DrawerAttribute), true)[0];
                MethodDrawer    methodDrawer    = MethodDrawerDatabase.GetDrawerForAttribute(drawerAttribute.GetType());
                if (methodDrawer != null)
                {
                    if (methodDrawer.DrawMethod(this.target, method))
                    {
                        this.serializedObject.ApplyModifiedProperties();
                        this.serializedObject.Update();
                        PropertyDrawerDatabase.ClearCache();
                    }
                }
            }
        }
Пример #7
0
 protected virtual void OnDisable()
 {
     PropertyDrawerDatabase.ClearCache();
 }