コード例 #1
0
        /// <summary>
        /// Draw all properties from begin to end, and return the rect taken up.
        /// </summary>
        private Rect DrawPropertyNestedRange(Rect position, int indentOffset, SerializedProperty begin, SerializedProperty end)
        {
            // Track the top so we know how tall the whole drawn area was
            float top = position.yMin;

            SerializedProperty cur = begin.Copy();

            while (!SerializedProperty.EqualContents(cur, end))
            {
                EditorGUI.indentLevel = cur.depth + indentOffset;
                position.y           += PROPERTY_MARGIN;

                StratusSerializedPropertyHandler curHandler = StratusScriptAttributeUtility.GetHandler(cur);
                position.height = curHandler.GetHeight(cur, StratusEditorUtility.TempContent(cur.displayName), cur.isExpanded);

                EditorGUI.BeginChangeCheck();
                curHandler.OnGUI(position, cur, null, true);
                position.y += position.height;

                if (EditorGUI.EndChangeCheck())
                {
                    break;
                }

                cur.NextVisible(false);
            }

            position.yMin = top;
            return(position);
        }
コード例 #2
0
        internal StratusSerializedPropertyHandler GetHandler(SerializedProperty property)
        {
            int propertyHash = GetPropertyHash(property);
            StratusSerializedPropertyHandler result = null;

            if (this.m_PropertyHandlers.TryGetValue(propertyHash, out result))
            {
                return(result);
            }
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Calculate the height taken up by all properties from begin to end.
        /// </summary>
        private float GetHeightNestedRange(SerializedProperty begin, SerializedProperty end)
        {
            float height = 0f;

            SerializedProperty cur = begin.Copy();

            while (!SerializedProperty.EqualContents(cur, end))
            {
                StratusSerializedPropertyHandler curHandler = StratusScriptAttributeUtility.GetHandler(cur);
                float curHeight = curHandler.GetHeight(cur, StratusEditorUtility.TempContent(cur.displayName), cur.isExpanded);
                height += curHeight + PROPERTY_MARGIN;
                cur.NextVisible(false);
            }

            return(height);
        }
コード例 #4
0
        internal void SetHandler(SerializedProperty property, StratusSerializedPropertyHandler handler)
        {
            int propertyHash = GetPropertyHash(property);

            m_PropertyHandlers[propertyHash] = handler;
        }
コード例 #5
0
        internal static StratusSerializedPropertyHandler GetHandler(SerializedProperty property)
        {
            if (property == null)
            {
                return(s_SharedNullHandler);
            }
            if (property.serializedObject.GetInspectorMode() != 0)
            {
                return(s_SharedNullHandler);
            }
            StratusSerializedPropertyHandler handler = propertyHandlerCache.GetHandler(property);

            if (handler != null)
            {
                return(handler);
            }
            Type type = null;
            List <PropertyAttribute> list = null;
            FieldInfo field = null;

            UnityEngine.Object targetObject = property.serializedObject.targetObject;
            if (targetObject is MonoBehaviour || targetObject is ScriptableObject)
            {
                field = GetFieldInfoFromProperty(property, out type);
                list  = GetFieldAttributes(field);
            }
            else
            {
                if (s_BuiltinAttributes == null)
                {
                    PopulateBuiltinAttributes();
                }
                if (list == null)
                {
                    list = GetBuiltinAttributes(property);
                }
            }
            handler = s_NextHandler;
            if (list != null)
            {
                for (int num = list.Count - 1; num >= 0; num--)
                {
                    handler.HandleAttribute(list[num], field, type);
                }
            }
            if (!handler.HasPropertyDrawer && type != null)
            {
                handler.HandleDrawnType(type, type, field, null);
            }
            if (handler.Empty)
            {
                propertyHandlerCache.SetHandler(property, s_SharedNullHandler);
                handler = s_SharedNullHandler;
            }
            else
            {
                propertyHandlerCache.SetHandler(property, handler);
                s_NextHandler = new StratusSerializedPropertyHandler();
            }
            return(handler);
        }