Beispiel #1
0
 protected override void DrawGUI(Rect position, Config config)
 {
     if (this.helpTopic != null)
     {
         EditorGUILayout.BeginHorizontal();
         {
             TCP2_GUI.HelpButtonSG2(this.helpTopic);
             TCP2_GUI.SubHeaderGray(label);
         }
         EditorGUILayout.EndHorizontal();
     }
     else
     {
         TCP2_GUI.SubHeaderGray(label);
     }
 }
Beispiel #2
0
            internal void DrawGUI(Config config)
            {
                bool guiEnabled = GUI.enabled;

                // update states
                this.enabled     = Enabled(config);
                this.highlighted = Highlighted(config);

                GUI.enabled = enabled;

                // by default, only show if top-level
                bool visible = indentLevel == 0;

                // if set, show all
                if (GlobalOptions.data.ShowDisabledFeatures)
                {
                    visible = true;
                }
                // else, show only if parent is enabled & highlighted
                else if (indentLevel > 0 && parent != null)
                {
                    visible = parent.enabled && parent.highlighted;
                }

                if (inline)
                {
                    visible = LastVisible;
                }

                visible &= (FoldoutStack.Count > 0) ? FoldoutStack.Peek() : true;

                ForceValue(config);

                if (customGUI)
                {
                    if (visible || ignoreVisibility)
                    {
                        DrawGUI(new Rect(0, 0, EditorGUIUtility.currentViewWidth, 0), config);
                        return;
                    }
                }
                else if (visible)
                {
                    //Total line rect
                    Rect position;
                    position = inline ? LastPositionInline : EditorGUILayout.GetControlRect();

                    if (halfWidth)
                    {
                        position.width = (position.width / 2f) - 8f;
                    }

                    //LastPosition is already halved
                    if (inline)
                    {
                        position.x += position.width + 16f;
                    }

                    //Last Position for inlined properties
                    LastPositionInline = position;

                    if (!inline)
                    {
                        //Help
                        if (showHelp)
                        {
                            var helpRect = HeaderRect(ref position, 20f);
                            TCP2_GUI.HelpButtonSG2(helpRect, label, string.IsNullOrEmpty(helpTopic) ? label : helpTopic);
                        }
                        else
                        {
                            HeaderRect(ref position, 20f);
                        }

                        const float barIndent = 2;                              // pixels for vertical bar indent
                        const float uiIndent  = 8;                              // pixels per indent level for UI

                        var horizontalRect = position;
                        var lineColor      = Color.black * (EditorGUIUtility.isProSkin ? 0.3f : 0.2f);
                        for (int i = 1; i <= indentLevel; i++)
                        {
                            // vertical bar to the left of indented lines
                            horizontalRect = position;
                            if (indentLevel > 0 && Event.current.type == EventType.Repaint)
                            {
                                var verticalRect = position;
                                verticalRect.width = 1;
                                verticalRect.x    += barIndent;
                                verticalRect.yMax -= 7;
                                verticalRect.yMin  = (indentLevel <= 0 || i > LastIndent) ? LastLowerBoundY : LastIndentY;
                                EditorGUI.DrawRect(verticalRect, lineColor);
                            }

                            // indent
                            HeaderRect(ref position, uiIndent);

                            // horizontal bar
                            horizontalRect.width  = horizontalRect.width - position.width;
                            horizontalRect.height = 1;
                            horizontalRect.xMin  += barIndent + 1;
                            horizontalRect.y     += position.height / 2;
                            if (indentLevel > 0 && i == indentLevel && Event.current.type == EventType.Repaint)
                            {
                                EditorGUI.DrawRect(horizontalRect, lineColor);
                            }
                        }

                        LastLowerBoundY = position.yMax;
                        LastIndentY     = horizontalRect.y;
                        LastIndent      = indentLevel;
                    }

                    //Label
                    var guiContent    = TempContent(label, tooltip);
                    var labelPosition = HeaderRect(ref position, inline ? (EditorStyles.label.CalcSize(guiContent)).x + 8f : LABEL_WIDTH - position.x);
                    TCP2_GUI.SubHeader(labelPosition, guiContent, this.highlighted && this.enabled);

                    //Actual property
                    DrawGUI(position, config);

                    LastVisible = visible;
                }

                GUI.enabled = guiEnabled;
            }