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(); }
private void CreateLink(InputData _input, OutputData _output) { selectedInput = null; selectedOutput = null; var newLink = new LinkData(_input, _output); if (constellationScript.IsLinkValid(newLink)) { constellationScript.AddLink(newLink); OnLinkAdded(newLink); undoable.AddAction(); GUI.RequestRepaint(); } }
public void CreateLink(InputData _input, OutputData _output, ConstellationEditorEvents.EditorEvents editorEvents) { if (isInstance) { constellationScript.IsDifferentThanSource = true; } selectedInput = null; selectedOutput = null; var newLink = new LinkData(_input, _output); if (constellationScript.IsLinkValid(newLink)) { constellationScript.AddLink(newLink); editorEvents(ConstellationEditorEvents.EditorEventType.LinkAdded, newLink.GUID); } }
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(); } }
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()); }