/// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var entry = this.ValueEntry;

            if (Event.current.type == EventType.Layout)
            {
                this.drawAsReference = entry.ValueState == PropertyValueState.Reference;
            }

            if (this.drawAsReference)
            {
                var targetProp = entry.Property.Tree.GetPropertyAtPath(entry.TargetReferencePath);

                if (targetProp == null)
                {
                    GUILayout.Label("Reference to " + entry.TargetReferencePath + ". But no property was found at path, which is a problem.");
                    return;
                }

                var isInReference = targetProp.Context.GetGlobal("is_in_reference", false);

                bool drawReferenceBox = true;

                if (!isInReference.Value)
                {
                    drawReferenceBox = !this.hideReferenceBox;
                }

                if (drawReferenceBox)
                {
                    SirenixEditorGUI.BeginToolbarBox();
                    SirenixEditorGUI.BeginToolbarBoxHeader();
                    Rect valueRect;
                    this.isToggled.Value = SirenixEditorGUI.Foldout(this.isToggled.Value, label, out valueRect);
                    GUI.Label(valueRect, "Reference to " + targetProp.Path, SirenixGUIStyles.LeftAlignedGreyMiniLabel);
                    SirenixEditorGUI.EndToolbarBoxHeader();
                    if (SirenixEditorGUI.BeginFadeGroup(entry.Context.Get(this, "k", 0), this.isToggled.Value))
                    {
                        bool previous = isInReference.Value;
                        isInReference.Value = true;
                        targetProp.Draw(label);
                        isInReference.Value = previous;
                    }
                    SirenixEditorGUI.EndFadeGroup();
                    SirenixEditorGUI.EndToolbarBox();
                }
                else
                {
                    bool previous = isInReference.Value;
                    isInReference.Value = true;
                    targetProp.Draw(label);
                    isInReference.Value = previous;
                }
            }
            else
            {
                this.CallNextDrawer(label);
            }
        }
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var property = this.Property;
            var name     = property.ChildResolver != null?property.ChildResolver.GetType().GetNiceName() : "None";

            SirenixEditorGUI.BeginToolbarBox(name);
            this.CallNextDrawer(label);
            SirenixEditorGUI.EndToolbarBox();
        }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var property = this.Property;

            var chain   = property.GetActiveDrawerChain();
            var drawers = chain.BakedDrawerArray;

            SirenixEditorGUI.BeginToolbarBox("Drawers");

            for (int i = 0; i < drawers.Length; i++)
            {
                bool highlight = drawers[i].GetType().Assembly != typeof(ShowDrawerChainAttributeDrawer).Assembly;

                if (highlight)
                {
                    GUIHelper.PushColor(Color.green);
                }

                if (i > this.drawnDepth)
                {
                    GUIHelper.PushColor(new Color(1, 1, 1, 0.5f));
                }

                EditorGUILayout.LabelField(i + ": " + drawers[i].GetType().GetNiceName() + (drawers[i].SkipWhenDrawing ? " (skipped)" : ""));
                var rect = GUILayoutUtility.GetLastRect();

                if (i > this.drawnDepth)
                {
                    GUIHelper.PopColor();
                }

                GUI.Label(rect, DrawerUtilities.GetDrawerPriority(drawers[i].GetType()).ToString(), SirenixGUIStyles.RightAlignedGreyMiniLabel);

                if (highlight)
                {
                    GUIHelper.PopColor();
                }
            }
            SirenixEditorGUI.EndToolbarBox();

            this.CallNextDrawer(label);

            this.drawnDepth = chain.CurrentIndex;
        }
        // Token: 0x06000A26 RID: 2598 RVA: 0x00031018 File Offset: 0x0002F218
        public void Draw(bool drawCodeExample)
        {
            if (TrickOverViewPreview.exampleGroupStyle == null)
            {
                TrickOverViewPreview.exampleGroupStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(1, 1, 10, 0)
                };
            }
            if (TrickOverViewPreview.previewStyle == null)
            {
                TrickOverViewPreview.previewStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(0, 0, 0, 0)
                };
            }
            GUILayout.BeginVertical(TrickOverViewPreview.exampleGroupStyle, new GUILayoutOption[0]);
            GUILayout.Label("Preview:", SirenixGUIStyles.BoldTitle, new GUILayoutOption[0]);
            GUILayout.BeginVertical(TrickOverViewPreview.previewStyle, GUILayoutOptions.ExpandWidth(true));
            Rect rect = GUIHelper.GetCurrentLayoutRect().Expand(4f, 0f);

            SirenixEditorGUI.DrawSolidRect(rect, EditorGUIUtility.isProSkin ? TrickOverViewPreview.previewBackgroundColorDark : TrickOverViewPreview.previewBackgroundColorLight, true);
            SirenixEditorGUI.DrawBorders(rect, 1, true);
            GUILayout.Space(8f);

            m_DrawCallbaclAction.Invoke(rect);
            this.tree = (this.tree ?? PropertyTree.Create(this.ExampleInfo.PreviewObject));
            this.tree.Draw(false);

            GUILayout.Space(8f);
            GUILayout.EndVertical();
            if (drawCodeExample && this.ExampleInfo.Code != null)
            {
                GUILayout.Space(12f);
                GUILayout.Label("Code", SirenixGUIStyles.BoldTitle, new GUILayoutOption[0]);
                Rect rect2 = SirenixEditorGUI.BeginToolbarBox(new GUILayoutOption[0]);
                SirenixEditorGUI.DrawSolidRect(rect2.HorizontalPadding(1f), SyntaxHighlighter.BackgroundColor, true);
                SirenixEditorGUI.BeginToolbarBoxHeader(22f);
                if (SirenixEditorGUI.ToolbarButton(this.showRaw ? "Highlighted" : "Raw", false))
                {
                    this.showRaw = !this.showRaw;
                }
                GUILayout.FlexibleSpace();
                if (SirenixEditorGUI.ToolbarButton("Copy", false))
                {
                    Clipboard.Copy <string>(this.ExampleInfo.Code);
                }
                SirenixEditorGUI.EndToolbarBoxHeader();
                if (TrickOverViewPreview.codeTextStyle == null)
                {
                    TrickOverViewPreview.codeTextStyle = new GUIStyle(SirenixGUIStyles.MultiLineLabel);
                    TrickOverViewPreview.codeTextStyle.normal.textColor  = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.active.textColor  = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.focused.textColor = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.wordWrap          = false;
                }
                GUIContent content = GUIHelper.TempContent(this.showRaw ? this.ExampleInfo.Code.TrimEnd(new char[]
                {
                    '\n',
                    '\r'
                }) : this.highlightedCode);
                Vector2 vector = TrickOverViewPreview.codeTextStyle.CalcSize(content);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(-3f);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUIHelper.PushEventType((Event.current.type == EventType.ScrollWheel) ? EventType.Used : Event.current.type);
                this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, new GUILayoutOption[]
                {
                    GUILayout.MinHeight(vector.y + 20f)
                });
                Rect rect3 = GUILayoutUtility.GetRect(vector.x + 50f, vector.y).AddXMin(4f).AddY(2f);
                if (this.showRaw)
                {
                    EditorGUI.SelectableLabel(rect3, this.ExampleInfo.Code, TrickOverViewPreview.codeTextStyle);
                    GUILayout.Space(-14f);
                }
                else
                {
                    GUI.Label(rect3, content, TrickOverViewPreview.codeTextStyle);
                }
                GUILayout.EndScrollView();
                GUIHelper.PopEventType();
                GUILayout.EndVertical();
                GUILayout.Space(-3f);
                GUILayout.EndHorizontal();
                GUILayout.Space(-3f);
                SirenixEditorGUI.EndToolbarBox();
            }
            GUILayout.EndVertical();
        }
        public void Draw(bool drawCodeExample)
        {
            if (exampleGroupStyle == null)
            {
                exampleGroupStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(1, 1, 10, 0)
                };
            }
            if (previewStyle == null)
            {
                previewStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(0, 0, 0, 0),
                };
            }

            GUILayout.BeginVertical(exampleGroupStyle);

            if (this.ExampleInfo.Description != null)
            {
                SirenixEditorGUI.BeginBox();
                GUILayout.BeginHorizontal();
                GUILayout.Space(23);
                GUILayout.Label(this.ExampleInfo.Description, SirenixGUIStyles.MultiLineLabel);

                var rect = GUILayoutUtility.GetLastRect();
                EditorIcons.X.Draw(rect.SubX(26).SetWidth(26).AlignCenterXY(20), EditorIcons.Info.Active);

                GUILayout.EndHorizontal();
                SirenixEditorGUI.EndBox();

                GUILayout.Space(12);
            }

            GUILayout.Label("Interactive Preview", SirenixGUIStyles.BoldTitle);
            GUILayout.BeginVertical(previewStyle, GUILayoutOptions.ExpandWidth(true));
            {
                Rect rect = GUIHelper.GetCurrentLayoutRect().Expand(4, 0);
                SirenixEditorGUI.DrawSolidRect(rect, EditorGUIUtility.isProSkin ? previewBackgroundColorDark : previewBackgroundColorLight);
                SirenixEditorGUI.DrawBorders(rect, 1);

                GUILayout.Space(8);
                this.tree = this.tree ?? PropertyTree.Create(this.ExampleInfo.PreviewObject);
                this.tree.Draw(false);
                GUILayout.Space(8);
            }
            GUILayout.EndVertical();

            if (drawCodeExample && this.ExampleInfo.Code != null)
            {
                GUILayout.Space(12);
                GUILayout.Label("Code", SirenixGUIStyles.BoldTitle);

                Rect rect = SirenixEditorGUI.BeginToolbarBox();
                SirenixEditorGUI.DrawSolidRect(rect.HorizontalPadding(1), SyntaxHighlighter.BackgroundColor);

                SirenixEditorGUI.BeginToolbarBoxHeader();
                {
                    if (SirenixEditorGUI.ToolbarButton(this.showRaw ? "Highlighted" : "Raw"))
                    {
                        this.showRaw = !this.showRaw;
                    }

                    GUILayout.FlexibleSpace();
                    if (SirenixEditorGUI.ToolbarButton("Copy"))
                    {
                        Clipboard.Copy(this.ExampleInfo.Code);
                    }
                }
                SirenixEditorGUI.EndToolbarBoxHeader();

                if (codeTextStyle == null)
                {
                    codeTextStyle = new GUIStyle(SirenixGUIStyles.MultiLineLabel);
                    codeTextStyle.normal.textColor  = SyntaxHighlighter.TextColor;
                    codeTextStyle.active.textColor  = SyntaxHighlighter.TextColor;
                    codeTextStyle.focused.textColor = SyntaxHighlighter.TextColor;
                    codeTextStyle.wordWrap          = false;
                }

                GUIContent codeContent = GUIHelper.TempContent(this.showRaw ? this.ExampleInfo.Code.TrimEnd('\n', '\r') : this.highlightedCode);
                Vector2    size        = codeTextStyle.CalcSize(codeContent);

                GUILayout.BeginHorizontal();
                GUILayout.Space(-3);
                GUILayout.BeginVertical();
                {
                    GUIHelper.PushEventType(Event.current.type == EventType.ScrollWheel ? EventType.Used : Event.current.type); // Prevent the code horizontal scroll view from eating the scroll event.

                    this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, GUILayout.MinHeight(size.y + 20));
                    var codeRect = GUILayoutUtility.GetRect(size.x + 50, size.y).AddXMin(4).AddY(2);

                    if (this.showRaw)
                    {
                        EditorGUI.SelectableLabel(codeRect, this.ExampleInfo.Code, codeTextStyle);
                        GUILayout.Space(-14);
                    }
                    else
                    {
                        GUI.Label(codeRect, codeContent, codeTextStyle);
                    }

                    GUILayout.EndScrollView();

                    GUIHelper.PopEventType();
                }
                GUILayout.EndVertical();
                GUILayout.Space(-3);
                GUILayout.EndHorizontal();
                GUILayout.Space(-3);

                SirenixEditorGUI.EndToolbarBox();
            }
            GUILayout.EndVertical();
        }
Пример #6
0
        public void Draw(bool drawCodeExample)
        {
            if (this.ExampleInfo.Description != null)
            {
                SirenixEditorGUI.BeginBox();
                GUILayout.Label(this.ExampleInfo.Description, SirenixGUIStyles.MultiLineLabel);
                SirenixEditorGUI.EndBox();
            }

            SirenixEditorGUI.BeginBox();
            {
                this.tree = this.tree ?? PropertyTree.Create(this.ExampleInfo.PreviewObject);
                this.tree.Draw(false);
            }
            SirenixEditorGUI.EndBox();

            if (drawCodeExample && this.ExampleInfo.Code != null)
            {
                GUILayout.Space(15);

                Rect rect = SirenixEditorGUI.BeginToolbarBox();
                SirenixEditorGUI.DrawSolidRect(rect.HorizontalPadding(1), SyntaxHighlighter.BackgroundColor);

                SirenixEditorGUI.BeginToolbarBoxHeader();
                {
                    if (SirenixEditorGUI.ToolbarButton(this.showRaw ? "Highlighted" : "Raw"))
                    {
                        this.showRaw = !this.showRaw;
                    }

                    GUILayout.FlexibleSpace();
                    if (SirenixEditorGUI.ToolbarButton("Copy"))
                    {
                        Clipboard.Copy(this.ExampleInfo.Code);
                    }
                }
                SirenixEditorGUI.EndToolbarBoxHeader();

                if (codeStyle == null)
                {
                    codeStyle = new GUIStyle(SirenixGUIStyles.MultiLineLabel);
                    codeStyle.normal.textColor  = SyntaxHighlighter.TextColor;
                    codeStyle.active.textColor  = SyntaxHighlighter.TextColor;
                    codeStyle.focused.textColor = SyntaxHighlighter.TextColor;
                    codeStyle.wordWrap          = false;
                }

                GUIContent codeContent = GUIHelper.TempContent(this.showRaw ? this.ExampleInfo.Code : this.highlightedCode);
                Vector2    size        = codeStyle.CalcSize(codeContent);

                this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, GUILayoutOptions.MinHeight(size.y + 20));
                var codeRect = GUILayoutUtility.GetRect(size.x + 50, size.y);

                if (this.showRaw)
                {
                    EditorGUI.SelectableLabel(codeRect, this.ExampleInfo.Code, codeStyle);
                }
                else
                {
                    GUI.Label(codeRect, codeContent, codeStyle);
                }

                GUILayout.EndScrollView();

                SirenixEditorGUI.EndToolbarBox();
            }
        }