public void DrawPaths(ClassTree tree) { foreach (ClassNode node in nodes) { node.DrawPaths(tree); } }
public void DrawPaths(ClassTree tree) { // Draw paths to children foreach (ClassNode child in tree.GetChildren(this)) { Vector2 startPos = ButtonPosition; Vector2 endPos = child.KnobPosition; Handles.DrawBezier(startPos, endPos, startPos, endPos, EditorUtils.LINE_COLOR, null, 3f); } }
public static bool OnOpenAsset(int instanceID, int line) { string assetPath = AssetDatabase.GetAssetPath(instanceID); ClassTree classTree = AssetDatabase.LoadAssetAtPath <ClassTree>(assetPath); if (classTree != null) { ShowWindow(); return(true); } return(false); }
public void DrawNodes(ClassTree tree, Rect area) { float tierheight = ClassTree.TIER_HEIGHT; float levelMarginWidth = ClassTree.LEVEL_MARGIN_WIDTH; float typeMarginWidth = ClassTree.TYPE_MARGIN_WIDTH; float nodeWidth = ClassTree.NODE_WIDTH; float nodeHeight = ClassTree.NODE_HEIGHT; float marginWidth = levelMarginWidth + typeMarginWidth; // Draw nodes int idx = 0; float sectionWidth = (area.width - marginWidth) / (nodes.Count + 1); float yOffset = (tierheight - nodeHeight) / 2 + 1; foreach (ClassNode node in nodes) { float xOffset = marginWidth + sectionWidth * (idx + 1) - nodeWidth / 2; node.Draw(tree, new Vector2(area.x + xOffset, area.y + yOffset)); idx++; } }
private void UpdateSelectedTree() { if (Selection.activeObject is ClassTree) { selectedTree = Selection.activeObject as ClassTree; selectedAssetPath = AssetDatabase.GetAssetPath(selectedTree.GetInstanceID()); if (!selectedTree.ContainsTier(1)) { selectedTree.AddTier(1, ClassTierType.Class); selectedTree.AddNode(1); } selectedTree.Initialize(); } else { selectedTree = null; selectedAssetPath = ""; } Repaint(); }
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); }
void OnEnable() { tree = serializedObject.targetObject as ClassTree; layers = serializedObject.FindProperty("layers"); }