/// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var pushLabelWidth = this.Attribute.LabelWidth > 0;

            if (label == null)
            {
                if (pushLabelWidth)
                {
                    GUIHelper.PushLabelWidth(this.Attribute.LabelWidth);
                }
                this.CallNextDrawer(label);
                if (pushLabelWidth)
                {
                    GUIHelper.PopLabelWidth();
                }
            }
            else
            {
                SirenixEditorGUI.BeginVerticalPropertyLayout(label);
                if (pushLabelWidth)
                {
                    GUIHelper.PushLabelWidth(this.Attribute.LabelWidth);
                }
                for (int i = 0; i < this.Property.Children.Count; i++)
                {
                    var child = this.Property.Children[i];
                    child.Draw(child.Label);
                }
                if (pushLabelWidth)
                {
                    GUIHelper.PopLabelWidth();
                }
                SirenixEditorGUI.EndVerticalPropertyLayout();
            }
        }
Ejemplo n.º 2
0
        private void DrawField(GUIContent label)
        {
            if (this.inlinePropertyAttr != null)
            {
                var pushLabelWidth = this.inlinePropertyAttr.LabelWidth > 0;
                if (label == null)
                {
                    if (pushLabelWidth)
                    {
                        GUIHelper.PushLabelWidth(this.inlinePropertyAttr.LabelWidth);
                    }
                    this.DrawInlinePropertyReferencePicker();
                    this.CallNextDrawer(null);
                    if (pushLabelWidth)
                    {
                        GUIHelper.PopLabelWidth();
                    }
                }
                else
                {
                    SirenixEditorGUI.BeginVerticalPropertyLayout(label);
                    this.DrawInlinePropertyReferencePicker();
                    if (pushLabelWidth)
                    {
                        GUIHelper.PushLabelWidth(this.inlinePropertyAttr.LabelWidth);
                    }
                    for (int i = 0; i < this.Property.Children.Count; i++)
                    {
                        var child = this.Property.Children[i];
                        child.Draw(child.Label);
                    }
                    if (pushLabelWidth)
                    {
                        GUIHelper.PopLabelWidth();
                    }
                    SirenixEditorGUI.EndVerticalPropertyLayout();
                }
            }
            else
            {
                Rect valueRect;
                bool hasKeyboadFocus;
                int  id;
                var  rect = SirenixEditorGUI.GetFeatureRichControlRect(null, out id, out hasKeyboadFocus, out valueRect);

                if (label != null)
                {
                    rect.width     = GUIHelper.BetterLabelWidth;
                    valueRect.xMin = rect.xMax;

                    if (this.drawChildren)
                    {
                        this.isToggled.Value = SirenixEditorGUI.Foldout(rect, this.isToggled.Value, label);
                    }
                    else if (Event.current.type == EventType.Repaint)
                    {
                        rect = EditorGUI.IndentedRect(rect);
                        GUI.Label(rect, label);
                    }
                }
                else if (this.drawChildren)
                {
                    if (EditorGUIUtility.hierarchyMode)
                    {
                        rect.width = 18;
                        var preev = EditorGUIUtility.hierarchyMode;
                        this.isToggled.Value = SirenixEditorGUI.Foldout(rect, this.isToggled.Value, GUIContent.none);
                    }
                    else
                    {
                        rect.width     = 18;
                        valueRect.xMin = rect.xMax;
                        var preev = EditorGUIUtility.hierarchyMode;
                        EditorGUIUtility.hierarchyMode = false;
                        this.isToggled.Value           = SirenixEditorGUI.Foldout(rect, this.isToggled.Value, GUIContent.none);
                        EditorGUIUtility.hierarchyMode = preev;
                    }
                }

                EditorGUI.BeginChangeCheck();
                var prev = EditorGUI.showMixedValue;
                if (this.ValueEntry.ValueState == PropertyValueState.ReferenceValueConflict)
                {
                    EditorGUI.showMixedValue = true;
                }
                var newValue = SirenixEditorFields.PolymorphicObjectField(valueRect, this.ValueEntry.WeakSmartValue, this.ValueEntry.BaseValueType, this.allowSceneObjects, hasKeyboadFocus, id);
                EditorGUI.showMixedValue = prev;

                if (EditorGUI.EndChangeCheck())
                {
                    this.ValueEntry.Property.Tree.DelayActionUntilRepaint(() =>
                    {
                        this.ValueEntry.WeakValues[0] = newValue;
                        for (int j = 1; j < this.ValueEntry.ValueCount; j++)
                        {
                            this.ValueEntry.WeakValues[j] = SerializationUtility.CreateCopy(newValue);
                        }
                    });
                }

                if (this.drawChildren)
                {
                    var toggle = this.ValueEntry.ValueState == PropertyValueState.NullReference ? false : this.isToggled.Value;
                    if (SirenixEditorGUI.BeginFadeGroup(this, toggle))
                    {
                        EditorGUI.indentLevel++;
                        this.CallNextDrawer(null);
                        EditorGUI.indentLevel--;
                    }
                    SirenixEditorGUI.EndFadeGroup();
                }
            }
        }