public void DrawWindow(int id, GUI.WindowFunction DrawNodeWindow, bool isNote) { //Only draw visible nodes if (!editor.InView(Rect)) { return; } if (DrawDescription) { DrawHelp(Description); } var defaultStyle = selected ? GUI.skin.GetStyle("flow node 0 on") : GUI.skin.GetStyle("flow node 0"); defaultStyle.alignment = TextAnchor.UpperRight; defaultStyle.margin.top = -5; if (node.Name != "Note") { Rect = GUI.Window(id, Rect, DrawNodeWindow, "", defaultStyle); } else { Rect = GUI.Window(id, new Rect(Rect.x, Rect.y, 120, 120), DrawNodeWindow, "", selected ? nodeConfig.NoteHover : GUI.skin.GetStyle("VCS_StickyNote")); } if (node.XPosition != Rect.x || node.YPosition != Rect.y) { nodeMovement = new Vector2(node.XPosition - Rect.x, node.YPosition - Rect.y); nodeMoved = true; } else { nodeMovement = Vector2.zero; nodeMoved = false; } node.XPosition = Rect.x; node.YPosition = Rect.y; }
public void DrawNodeCurve(Rect start, Rect end, Color color) { Vector3 startPos = new Vector3(start.x + start.width, start.y + start.height / 2, 0); Vector3 endPos = new Vector3(end.x, end.y + end.height / 2, 0); if (!editor.InView(PointsToRect(startPos, endPos))) { return; } Vector3 startTan = startPos + Vector3.right * 50; Vector3 endTan = endPos + Vector3.left * 50; //Smoother bezier curve for close distance var distance = Vector3.Distance(startPos, endPos); if (distance < 100) { startTan = startPos + Vector3.right * (distance * 0.5f); endTan = endPos + Vector3.left * (distance * 0.5f); } Handles.DrawBezier(startPos, endPos, startTan, endTan, color, null, 5); }