private void EditNode(Event e) { BaseNode editNode = null; foreach (var n in nodeList) { if (EditingNode == n.uid) { editNode = n; } } if (editNode != null && editing) { Rect editRect = new Rect(150, 131, position.width - 300, position.height - 231); Rect borderRect = new Rect(148, 98, position.width - 296, position.height - 196); Rect closeRect = new Rect(position.width - 177, 102, 25, 25); EditorGUI.DrawRect(borderRect, Color.black); EditorGUI.DrawRect(editRect, Color.gray); GUI.DrawTexture(closeRect, (Texture)Resources.Load("close")); if (e.type == EventType.MouseDown && e.button == 0) { if (closeRect.Contains(e.mousePosition)) { editing = false; EditingNode = null; } } editNode.Display(editRect); } }
//Also Edit private void RemoveNode(Event e) { if (e.type == EventType.MouseDown && e.button == 1) { bool found = false; foreach (var n in nodeList) { Rect r = new Rect(n.xLocation, n.yLocation, n.width, n.height); if (r.Contains(e.mousePosition)) { foundNode = n.uid; found = true; } } if (found) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("edit node"), false, Edit); menu.AddItem(new GUIContent("remove this node"), false, Remove); menu.AddItem(new GUIContent("set as output"), false, SetOutput); menu.ShowAsContext(); } } }
public BaseNode() { uid = new _UUID(); }
void Edit() { EditingNode = foundNode; editing = true; Repaint(); }
private void CreateConnection(Event e) { if (CreatingConn && connCreatingnode != null) { if (e.type == EventType.Repaint) { BaseNode bn = null; foreach (var n in nodeList) { if (n.uid == connCreatingnode) { bn = n; } } if (bn != null) { Vector3 start = new Vector3(e.mousePosition.x, e.mousePosition.y, 0); Vector3 end = new Vector3(bn.xLocation + bn.width, bn.yLocation + 25 + 6f, 0); Handles.BeginGUI(); Handles.color = Color.white; Handles.DrawAAPolyLine(5, new Vector3[] { start, end }); Handles.EndGUI(); } } else if (e.type == EventType.MouseUp) { //muis is omhoog gegaan //loop through all nodes for (int n = 0; n < nodeList.Count; n++) { //get inputs var input = nodeList[n].getInputs(); //check of de inputs null zijn if (input != null) { //loop through inputs int y = 25; foreach (var i in input) { //maak locatie van de inputs Rect r = new Rect(nodeList[n].xLocation, nodeList[n].yLocation + y, 20, 14); //kijk of de input de muispositie bevat if (r.Contains(e.mousePosition)) { //set the input to the new input foreach (var ni in nodeList) { if (ni.uid == connCreatingnode) { nodeList[n].setInput(y == 25 ? 0 : 1, ni); } } } y += 18; } } } CreatingConn = false; connCreatingnode = null; } } else { if (e.type == EventType.MouseDown && e.button == 0) { foreach (var n in nodeList) { Rect rs = new Rect(n.xLocation + n.width - 20, n.yLocation + 25, 20, 14); if (rs.Contains(e.mousePosition)) { holdingNode = null; CreatingConn = true; connCreatingnode = n.uid; return; } } } } }