public NodeData AddNode(string _nodeName, string _namespace) { var newNode = constellationScript.AddNode(nodesFactory.GetNode(_nodeName, _namespace)); newNode.XPosition = editorScrollPos.x + (panelSize.x * 0.5f); newNode.YPosition = editorScrollPos.y + (panelSize.y * 0.5f); var newNodeWindow = new NodeView(newNode, this, nodeConfig, constellationScript); Nodes.Add(newNodeWindow); undoable.AddAction(); OnNodeAdded(newNode); return(newNode); }
public void DrawNodeWindow(int id) { if (id < Nodes.Count) { if (Nodes[id].NodeExist()) { Nodes[id].DrawContent(HelpRequested); } else { OnNodeRemoved(Nodes[id].node); Nodes.Remove(Nodes[id]); undoable.AddAction(); } } if (Event.current.delta == Vector2.zero && isDraggingWindow && Event.current.isMouse) { undoable.AddAction(); isDraggingWindow = false; if (isInstance) { constellationScript.IsDifferentThanSource = true; } } else if (Event.current.button == 0) { isDraggingWindow = true; } var script = constellationScript.script; if (script.Nodes != null) { script.Nodes = script.Nodes.OrderBy(x => x.YPosition).ToList(); } if (script.Links != null) { script.Links = script.Links.OrderBy(x => x.outputPositionY).ToList(); } if (Event.current.button == 0) { GUI.DragWindow(); } if (constellationScript != null) { EditorUtility.SetDirty(constellationScript); } }
public void CreateLink(InputData _input, OutputData _output) { if (isInstance) { constellationScript.IsDifferentThanSource = true; } selectedInput = null; selectedOutput = null; var newLink = new LinkData(_input, _output); if (constellationScript.IsLinkValid(newLink)) { constellationScript.AddLink(newLink); OnLinkAdded(newLink); undoable.AddAction(); GUI.RequestRepaint(); } }