public NodeData AddNode(string _nodeName, string _namespace, Vector2 panelSize, Vector2 editorScrollPos) { if (isInstance) { constellationScript.IsDifferentThanSource = true; } var nodeObject = nodesFactory.GetNode(_nodeName, _namespace); if (nodeObject.Name == Constellation.Custom.CustomNode.NAME) { var customNode = nodeObject.NodeType as ICustomNode; customNode.SetNode(constellationScripts); } var newNode = constellationScript.AddNode(nodeObject); if (nodeObject.Name == Constellation.Custom.CustomNode.NAME) { newNode.OverrideDisplayedName = _nodeName; } newNode.XPosition = editorScrollPos.x + (panelSize.x * 0.5f); newNode.YPosition = editorScrollPos.y + (panelSize.y * 0.5f); var newNodeWindow = new NodeView(newNode, visibleObject, nodeConfig, constellationScript, linkEditor); Nodes.Add(newNodeWindow); undoable.AddAction(); OnNodeAdded(newNode); nodeEditorSelection.UnselectAll(); return(newNode); }
public void OpenConstellationInstance(Constellation.Constellation constellation, string instanceSourcePath) { var constellationScript = ScriptableObject.CreateInstance <ConstellationScript> (); constellationScript.IsInstance = true; var path = "Assets/Constellation/Editor/EditorData/Temp/" + constellation.Name + "(Instance).asset"; if (path == null || path == "") { Script = null; return; } Script = constellationScript; AssetDatabase.CreateAsset(constellationScript, path); var nodes = constellation.GetNodes(); var links = constellation.GetLinks(); if (EditorData.CurrentInstancePath == null) { EditorData.CurrentInstancePath = new List <ConstellationInstanceObject> (); } currentInstancePath = new List <ConstellationInstanceObject> (EditorData.CurrentInstancePath); var newInstanceObject = new ConstellationInstanceObject(path, instanceSourcePath); currentInstancePath.Add(newInstanceObject); currentPath = new List <string> (EditorData.LastOpenedConstellationPath); if (!currentPath.Contains(path)) { currentPath.Insert(0, path); } else { currentPath.Remove(path); currentPath.Insert(0, path); } foreach (var node in nodes) { Script.AddNode(node); } foreach (var link in links) { Script.AddLink(link); } SaveEditorData(); }
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 AddNode(string nodeName, string nodeNamespace, ConstellationEditorEvents.EditorEvents callback) { var newNode = NodeFactory.GetNode(nodeName, nodeNamespace); var nodeData = new NodeData(newNode); nodeData = ConstellationScript.AddNode(nodeData); nodeData.XPosition = 0; nodeData.YPosition = 0; var newNodeView = new NodeView(nodeData); Nodes.Add(newNodeView); newNodeView.UpdateNodeSize(0, 0); newNodeView.SetPosition(ScrollPosition.x + (windowSizeX * 0.5f), ScrollPosition.y + (windowSizeY * 0.5f)); newNodeView.LockNodePosition(); callback(ConstellationEditorEvents.EditorEventType.NodeAdded, nodeData.Guid); SetNodeToFirst(newNodeView); }
public NodeData AddNode(string _nodeName, string _namespace, Vector2 panelSize, Vector2 editorScrollPos) { if (isInstance) { constellationScript.IsDifferentThanSource = true; } 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, visibleObject, nodeConfig, constellationScript, linkEditor); Nodes.Add(newNodeWindow); undoable.AddAction(); OnNodeAdded(newNode); nodeEditorSelection.UnselectAll(); return(newNode); }
public void OpenConstellationInstance <T> (Constellation.Constellation constellation, string instanceSourcePath) where T : ConstellationScript { var constellationScript = ScriptableObject.CreateInstance <T>(); constellationScript.IsInstance = true; constellationScript.CanChangeType = false; var path = "Assets/Constellation/Editor/EditorData/Temp/" + constellation.Name + "(Instance).asset"; Script = constellationScript; AssetDatabase.CreateAsset(constellationScript, path); var nodes = constellation.GetNodes(); var links = constellation.GetLinks(); var newInstanceObject = new ConstellationScriptInfos(instanceSourcePath, ConstellationScriptInfos.ConstellationScriptTag.NoTag, true, path); OpenedScripts = new List <ConstellationScriptInfos>(EditorData.LastOpenedConstellationPath); if (!OpenedScripts.Contains(newInstanceObject)) { OpenedScripts.Insert(0, newInstanceObject); } else { OpenedScripts.Remove(newInstanceObject); OpenedScripts.Insert(0, newInstanceObject); } foreach (var node in nodes) { Script.AddNode(node); } foreach (var link in links) { Script.AddLink(link); } SaveEditorData(); }
public NodeData[] PasteClipBoard(ConstellationScript constellation) { if (nodes == null) { return(null); } if (nodes.Count == 0) { return(null); } var pastedNodes = new List <NodeData> (); var pastedLinks = new List <LinkData> (); foreach (var node in nodes) { var newNode = new NodeData(node); newNode.XPosition = node.XPosition; newNode.YPosition = node.YPosition; pastedNodes.Add(newNode); } foreach (var link in links) { InputData input = null; OutputData output = null; for (var i = 0; i < nodes.Count; i++) { for (var j = 0; j < nodes[i].GetInputs().Length; j++) { if (link.Input.Guid == nodes[i].GetInputs() [j].Guid) { input = nodes[i].GetInputs() [j]; } } for (var k = 0; k < nodes[i].GetOutputs().Length; k++) { if (link.Output.Guid == nodes[i].GetOutputs() [k].Guid) { output = nodes[i].GetOutputs() [k]; } } } if (input != null && output != null) { pastedLinks.Add(new LinkData(input, output)); } } foreach (var node in pastedNodes) { constellation.AddNode(node); } foreach (var link in pastedLinks) { constellation.AddLink(link); } nodes = null; links = null; return(pastedNodes.ToArray()); }