void OnGUI() { if (windowsToAttach.Count == 2) { Undo.RecordObject(currentGo, "connection"); attachedWindows.Add(windowsToAttach[0]); attachedWindows.Add(windowsToAttach[1]); attachNodes[0].Connect(attachNodes[1]); windowsToAttach = new List <int>(); attachNodes = new List <CraneNode>(); EditorUtility.SetDirty(currentGo); } if (attachedWindows.Count >= 2) { for (int i = 0; i < attachedWindows.Count; i += 2) { DrawNodeCurve(windows[attachedWindows[i]], windows[attachedWindows[i + 1]]); } } BeginWindows(); if (GUILayout.Button("Create Node")) { windows.Add(new Rect(10, 10, 100, 100)); } for (int i = 0; i < windows.Count; i++) { windows[i] = GUI.Window(i, windows[i], DrawNodeWindow, "Window " + i); } if (Event.current.type == EventType.DragExited) { Debug.Log("DragExit event, mousePos:" + Event.current.mousePosition + "window pos:" + position); foreach (Object obj in DragAndDrop.objectReferences) { if (obj.GetType() == typeof(GameObject)) { windows = new List <Rect>(); if (((GameObject)obj).GetComponent <CranePath>()) { currentGo = ((GameObject)obj).GetComponent <CranePath>(); foreach (var node in currentGo.nodes) { windows.Add(new Rect(10, 10, 100, 100)); node.connections = new List <Connection>(); } } } } } EndWindows(); }
// Use this for initialization protected override void Start() { base.Start(); path = GetComponent <CranePath>(); cranePart.transform.position = path.nodes[0].position; }