internal static PropertyHandler GetHandler(SerializedProperty property)
        {
            if (property == null || property.serializedObject.inspectorMode != InspectorMode.Normal)
            {
                return(ScriptAttributeUtility.s_SharedNullHandler);
            }
            PropertyHandler handler1 = ScriptAttributeUtility.propertyHandlerCache.GetHandler(property);

            if (handler1 != null)
            {
                return(handler1);
            }
            System.Type type = (System.Type)null;
            List <PropertyAttribute> propertyAttributeList = (List <PropertyAttribute>)null;

            System.Reflection.FieldInfo field        = (System.Reflection.FieldInfo)null;
            UnityEngine.Object          targetObject = property.serializedObject.targetObject;
            if (targetObject is MonoBehaviour || targetObject is ScriptableObject)
            {
                field = ScriptAttributeUtility.GetFieldInfoFromProperty(property, out type);
                propertyAttributeList = ScriptAttributeUtility.GetFieldAttributes(field);
            }
            else
            {
                if (ScriptAttributeUtility.s_BuiltinAttributes == null)
                {
                    ScriptAttributeUtility.PopulateBuiltinAttributes();
                }
                if (propertyAttributeList == null)
                {
                    propertyAttributeList = ScriptAttributeUtility.GetBuiltinAttributes(property);
                }
            }
            PropertyHandler handler2 = ScriptAttributeUtility.s_NextHandler;

            if (propertyAttributeList != null)
            {
                for (int index = propertyAttributeList.Count - 1; index >= 0; --index)
                {
                    handler2.HandleAttribute(propertyAttributeList[index], field, type);
                }
            }
            if (!handler2.hasPropertyDrawer && type != null)
            {
                handler2.HandleDrawnType(type, type, field, (PropertyAttribute)null);
            }
            if (handler2.empty)
            {
                ScriptAttributeUtility.propertyHandlerCache.SetHandler(property, ScriptAttributeUtility.s_SharedNullHandler);
                handler2 = ScriptAttributeUtility.s_SharedNullHandler;
            }
            else
            {
                ScriptAttributeUtility.propertyHandlerCache.SetHandler(property, handler2);
                ScriptAttributeUtility.s_NextHandler = new PropertyHandler();
            }
            return(handler2);
        }
Beispiel #2
0
        internal static PropertyHandler GetHandler(SerializedProperty property)
        {
            PropertyHandler result;

            if (property == null)
            {
                result = ScriptAttributeUtility.s_SharedNullHandler;
            }
            else if (property.serializedObject.inspectorMode != InspectorMode.Normal)
            {
                result = ScriptAttributeUtility.s_SharedNullHandler;
            }
            else
            {
                PropertyHandler handler = ScriptAttributeUtility.propertyHandlerCache.GetHandler(property);
                if (handler != null)
                {
                    result = handler;
                }
                else
                {
                    Type type = null;
                    List <PropertyAttribute> list   = null;
                    FieldInfo          field        = null;
                    UnityEngine.Object targetObject = property.serializedObject.targetObject;
                    if (targetObject is MonoBehaviour || targetObject is ScriptableObject)
                    {
                        field = ScriptAttributeUtility.GetFieldInfoFromProperty(property, out type);
                        list  = ScriptAttributeUtility.GetFieldAttributes(field);
                    }
                    else
                    {
                        if (ScriptAttributeUtility.s_BuiltinAttributes == null)
                        {
                            ScriptAttributeUtility.PopulateBuiltinAttributes();
                        }
                        if (list == null)
                        {
                            list = ScriptAttributeUtility.GetBuiltinAttributes(property);
                        }
                    }
                    handler = ScriptAttributeUtility.s_NextHandler;
                    if (list != null)
                    {
                        for (int i = list.Count - 1; i >= 0; i--)
                        {
                            handler.HandleAttribute(list[i], field, type);
                        }
                    }
                    if (!handler.hasPropertyDrawer && type != null)
                    {
                        handler.HandleDrawnType(type, type, field, null);
                    }
                    if (handler.empty)
                    {
                        ScriptAttributeUtility.propertyHandlerCache.SetHandler(property, ScriptAttributeUtility.s_SharedNullHandler);
                        handler = ScriptAttributeUtility.s_SharedNullHandler;
                    }
                    else
                    {
                        ScriptAttributeUtility.propertyHandlerCache.SetHandler(property, handler);
                        ScriptAttributeUtility.s_NextHandler = new PropertyHandler();
                    }
                    result = handler;
                }
            }
            return(result);
        }