void DrawSingleNode(LogicNode node) { Rect frameRect = node.frameRect; //注意这里不能用Button函数, 因为会导致Event.current检测不到事件,应该是因为这个函数判断鼠标在Button上面的时候会调用Event.use() Color guiColor = GUI.color; GUI.color = node == curSelectedNode ? Color.yellow : guiColor; GUI.Box(node.frameRect, "", GUI.skin.FindStyle("button")); GUI.color = guiColor; Rect typeRect = new Rect(frameRect.x, frameRect.y + 10, frameRect.width, 30); GUI.Label(typeRect, node.GetType().Name); int width = 20; GUI.Box(node.inputRect, LogicTreeUIUtility.DotIcon); GUI.Box(node.outPutRect, LogicTreeUIUtility.DotIcon); if (node.linkNodes.Count > 0) { Vector2 startPos = node.OutputPos; for (int i = 0; i < node.linkNodes.Count; i++) { LogicNode linkNode = node.linkNodes[i]; Vector2 endPos = linkNode.InputPos; LogicTreeUIUtility.DrawBezierBy2Points(startPos, endPos); } } }
void DrawCreatedNodes() { for (int i = 0; i < CurLogicTree.nodeList.Count; i++) { LogicNode node = CurLogicTree.nodeList[i]; DrawSingleNode(node); } if (dragFlag == DragFlag.InputNode || dragFlag == DragFlag.OutputNode) { Vector2 start = dragFlag == DragFlag.InputNode ? curDragControlNode.InputPos : curDragControlNode.OutputPos; LogicTreeUIUtility.DrawBezierBy2Points(start, Event.current.mousePosition); Repaint(); } }