public override bool OnGUILayout(SerializedProperty property, GUIContent label, bool includeChildren, GUILayoutOption[] options)
        {
            bool cancelDraw = false;

            if (_modifiers != null)
            {
                for (int i = 0; i < _modifiers.Count; i++)
                {
                    _modifiers[i].OnBeforeGUI(property, ref cancelDraw);
                }
            }

            bool result = false;

            if (!cancelDraw)
            {
                result = base.OnGUILayout(property, label, includeChildren, options);
            }
            PropertyHandlerValidationUtility.AddAsHandled(property, this);

            if (_modifiers != null)
            {
                for (int i = 0; i < _modifiers.Count; i++)
                {
                    _modifiers[i].OnPostGUI(property);
                }
            }

            return(result);
        }
        public bool OnGUILayout(SerializedProperty property, GUIContent label, bool includeChildren, GUILayoutOption[] options)
        {
            if (_visibleDrawer == null)
            {
                this.Init();
            }

            property = property.Copy();
            if (label == null)
            {
                label = EditorHelper.TempContent(property.displayName);
            }

            if (_visibleDrawer is IArrayHandlingPropertyDrawer || !property.isArray)
            {
                if (label == null)
                {
                    label = EditorHelper.TempContent(property.displayName);
                }
                var rect = EditorGUILayout.GetControlRect(true, _visibleDrawer.GetPropertyHeight(property, label), options);
                _visibleDrawer.OnGUI(rect, property, label);
                PropertyHandlerValidationUtility.AddAsHandled(property, this);
                return(!includeChildren && property.isExpanded);
            }
            else
            {
                if (includeChildren && property.isExpanded)
                {
                    var rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
                    property.isExpanded = EditorGUI.Foldout(rect, property.isExpanded, label);

                    EditorGUI.indentLevel++;
                    rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
                    property.arraySize = Mathf.Max(0, EditorGUI.IntField(rect, "Size", property.arraySize));

                    var lbl = EditorHelper.TempContent("");
                    for (int i = 0; i < property.arraySize; i++)
                    {
                        var pchild = property.GetArrayElementAtIndex(i);
                        lbl.text = pchild.displayName;
                        var h = _visibleDrawer.GetPropertyHeight(pchild, lbl);
                        rect = EditorGUILayout.GetControlRect(true, h);
                        _visibleDrawer.OnGUI(rect, pchild, lbl);
                    }

                    EditorGUI.indentLevel--;
                    PropertyHandlerValidationUtility.AddAsHandled(property, this);
                    return(true);
                }
                else
                {
                    property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label);
                    PropertyHandlerValidationUtility.AddAsHandled(property, this);
                    return(false);
                }
            }
        }
Ejemplo n.º 3
0
        public override bool OnGUILayout(SerializedProperty property, GUIContent label, bool includeChildren, GUILayoutOption[] options)
        {
            if (label == null)
            {
                label = EditorHelper.TempContent(property.displayName, _customTooltip ?? property.tooltip);
            }
            else if (string.IsNullOrEmpty(label.tooltip) && !string.IsNullOrEmpty(_customTooltip))
            {
                label         = EditorHelper.CloneContent(label);
                label.tooltip = _customTooltip;
            }

            bool cancelDraw = false;

            if (_modifiers != null)
            {
                for (int i = 0; i < _modifiers.Count; i++)
                {
                    _modifiers[i].OnBeforeGUI(property, ref cancelDraw);
                }
            }

            bool result = false;

            if (!cancelDraw)
            {
                result = base.OnGUILayout(property, label, includeChildren, options);
            }
            PropertyHandlerValidationUtility.AddAsHandled(property, this);

            if (_modifiers != null)
            {
                for (int i = 0; i < _modifiers.Count; i++)
                {
                    _modifiers[i].OnPostGUI(property);
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
        public override bool OnGUI(Rect position, SerializedProperty property, GUIContent label, bool includeChildren)
        {
            if (_modifiers != null)
            {
                for (int i = 0; i < _modifiers.Count; i++)
                {
                    _modifiers[i].OnBeforeGUI(property);
                }
            }

            bool result = base.OnGUI(position, property, label, includeChildren);

            PropertyHandlerValidationUtility.AddAsHandled(property, this);

            if (_modifiers != null)
            {
                for (int i = 0; i < _modifiers.Count; i++)
                {
                    _modifiers[i].OnPostGUI(property);
                }
            }

            return(result);
        }