public void Draw(ClassTree tree, Rect area) { displayRect = area; float levelMarginWidth = ClassTree.LEVEL_MARGIN_WIDTH; float typeMarginWidth = ClassTree.TYPE_MARGIN_WIDTH; Color dividerColor = isSelected ? EditorUtils.HIGHLIGHTED_COLOR : EditorUtils.BACKGROUND_COLOR; // Draw dividing lines EditorUtils.DrawBox(new Rect(area.x, area.y, area.width, 2), dividerColor); EditorUtils.DrawBox(new Rect(area.x, area.y + area.height, area.width, 2), dividerColor); // Draw margin labels GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.alignment = TextAnchor.MiddleCenter; string levelText = EditorUtils.TrimStringToFit($"Level {level}", levelMarginWidth, labelStyle); GUI.Label(new Rect(area.x + 1, area.y + area.height / 2 - 10, levelMarginWidth, 20), levelText, labelStyle); string typeText = EditorUtils.TrimStringToFit($"{tierType.ToString()}", typeMarginWidth, labelStyle); GUI.Label(new Rect(area.x + levelMarginWidth + 3, area.y + area.height / 2 - 10, typeMarginWidth, 20), typeText, labelStyle); }
public void Draw(ClassTree tree, Vector2 position) { Color borderColor = isSelected ? EditorUtils.HIGHLIGHTED_COLOR : EditorUtils.BORDER_COLOR; float nodeWidth = ClassTree.NODE_WIDTH; float nodeHeight = ClassTree.NODE_HEIGHT; KnobPosition = new Vector2(position.x + nodeWidth / 2, position.y); ButtonPosition = new Vector2(position.x + nodeWidth / 2, position.y + nodeHeight); // Draw main node body displayRect = new Rect(position.x, position.y, nodeWidth, nodeHeight); EditorUtils.DrawBorderBox(displayRect, EditorUtils.BACKGROUND_COLOR, 2, borderColor); // Draw path connector knob if (level > 1) { Vector2 knobSize = Vector2.one * 8f; GUI.Box(new Rect(KnobPosition - knobSize / 2, knobSize), "", GUI.skin.button); } // Draw path edit button Vector2 buttonSize = Vector2.one * 12f; if (GUI.Button(new Rect(ButtonPosition - buttonSize / 2 - Vector2.up * 1, buttonSize), "")) { tree.StartPathEdit(this); } // Draw node label GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.alignment = TextAnchor.MiddleCenter; string nodeText = EditorUtils.TrimStringToFit(nodeType.ToString(), nodeWidth, labelStyle); GUI.Label(displayRect, nodeText, labelStyle); }