public void OpenConstellationInstance(Constellation.Constellation constellation, string path) { scriptDataService = new ConstellationEditorDataService(); scriptDataService.OpenConstellationInstance(constellation, path); CurrentEditedInstancesName = scriptDataService.currentInstancePath.ToArray(); Setup(); }
public void Update(Constellation.Constellation constellation) { foreach (var node in constellation.GetNodes()) { foreach (var nodeData in NodeEditorNodes.GetNodes()) { if (node.Guid == nodeData.node.Guid) { for (var i = 0; i < node.GetAttributes().Length; i++) { if (!nodeData.IsAttributeValueChanged()) { nodeData.GetData().AttributesData[i].Value.Set(node.GetAttributes() [i].Value.GetString()); if (node.NodeType is IAttributeUpdate) { IAttributeUpdate needAttributeUpdate = node.NodeType as IAttributeUpdate; needAttributeUpdate.OnAttributesUpdate(); } } else { if (isInstance) { constellationScript.IsDifferentThanSource = true; } node.GetAttributes() [i].Value.Set(nodeData.GetData().AttributesData[i].Value); node.NodeType.Receive(nodeData.GetData().AttributesData[i].Value, new Constellation.Input("0000-0000-0000-0000", 999, true, "editor", "none")); } } } } } }
public void OpenConstellationInstance <T>(Constellation.Constellation constellation, string path) where T : ConstellationScript { ScriptDataService.OpenConstellationInstance <T>(constellation, path); ConstellationScript = ScriptDataService.Script; ConstellationScript.ScriptAssembly = ScriptDataService.GetEditorData().ScriptAssembly; SetupNodeWindow(); }
public void Initialize() { if (ConstellationData == null && Application.isPlaying) { this.enabled = false; throw new NoConstellationAttached(this); } if (isInitialized) // do not initialize twice { return; } if (ConstellationComponent.eventSystem == null) { eventSystem = new ConstellationEventSystem(); } if (NodesFactory.Current == null) { nodeFactory = new NodesFactory(ConstellationData?.ScriptAssembly?.GetAllScriptData()); } else { nodeFactory = NodesFactory.Current; } var nodes = ConstellationData.GetNodes(); constellation = new Constellation(); SetNodes(nodes); var links = ConstellationData.GetLinks(); foreach (LinkData link in links) { var input = constellation.GetInput(link.Input.Guid); var output = constellation.GetOutput(link.Output.Guid); if (input != null && output != null) { constellation.AddLink(new Link(constellation.GetInput(link.Input.Guid), constellation.GetOutput(link.Output.Guid), constellation.GetOutput(link.Output.Guid).Type, link.GUID)); } } SetUnityObject(); constellation.Initialize(System.Guid.NewGuid().ToString(), ConstellationData.name); if (constellation.GetInjector() is IAwakable) { constellation.GetInjector().OnAwake(); } isInitialized = true; }
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 void Update(Constellation.Constellation constellation, ConstellationEditorEvents.EditorEvents editorEvents) { foreach (var node in constellation.GetNodes()) { foreach (var nodeData in Nodes) { if (node.Guid == nodeData.NodeData.Guid) { var changedParameters = nodeData.IsParameterValueChanged(); if (changedParameters.Length == 0) { for (var i = 0; i < node.GetParameters().Length; i++) { nodeData.NodeData.ParametersData[i].Value.Set(node.GetParameters()[i].Value.GetString()); } node.XPosition = nodeData.GetPositionX(); node.YPosition = nodeData.GetPositionY(); node.XSize = nodeData.GetSizeX(); node.YSize = nodeData.GetSizeY(); } else { for (var i = 0; i < node.GetParameters().Length; i++) { if (changedParameters.Contains(i)) { if (ConstellationScript.IsInstance) { ConstellationScript.IsDifferentThanSource = true; } node.GetParameters()[i].Value.Set(nodeData.NodeData.ParametersData[i].Value); node.NodeType.Receive(nodeData.NodeData.ParametersData[i].Value, new Constellation.Input("0000-0000-0000-0000", Parameter.ParameterInputID + i, true, "editor", "none")); if (node.NodeType is IParameterUpdate) { IParameterUpdate needAttributeUpdate = node.NodeType as IParameterUpdate; needAttributeUpdate.OnParametersUpdate(); } } } } } } } }
public void Awake() { if (ConstellationBehaviour.eventSystem == null) { eventSystem = new ConstellationEventSystem(); } if (NodesFactory.Current == null) { nodeFactory = new NodesFactory(); } else { nodeFactory = NodesFactory.Current; } if (ConstellationData == null && Application.isPlaying) { this.enabled = false; Debug.LogError("Constellation Error: No Constellation attached to " + this.gameObject); return; } var nodes = ConstellationData.GetNodes(); Constellation = new Constellation(); SetNodes(nodes); var links = ConstellationData.GetLinks(); foreach (LinkData link in links) { Constellation.AddLink(new Link(Constellation.GetInput(link.Input.Guid), Constellation.GetOutput(link.Output.Guid), Constellation.GetOutput(link.Output.Guid).Type), "none"); } SetUnityObject(); SetConstellationEvents(); foreach (var awakables in Awakables) { awakables.OnAwake(); } }
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 void Update(Constellation.Constellation constellation) { foreach (var node in constellation.GetNodes()) { foreach (var nodeData in Nodes) { if (node.Guid == nodeData.node.Guid) { for (var i = 0; i < node.GetAttributes().Length; i++) { if (!nodeData.IsAttributeValueChanged()) { nodeData.GetData().AttributesData[i].Value.Set(node.GetAttributes() [i].Value.GetString()); } else { node.GetAttributes() [i].Value.Set(nodeData.GetData().AttributesData[i].Value); node.NodeType.Receive(nodeData.GetData().AttributesData[i].Value, new Constellation.Input("0000-0000-0000-0000", 999, true, "editor", "none")); } } } } } }
public Injector(Constellation constellation) { logger = new Services.Logger(); Constellation = constellation; }
public void OpenConstellationInstance(Constellation.Constellation constellation, string path) { ScriptDataService.OpenConstellationInstance(constellation, path); ConstellationScript = ScriptDataService.Script; SetupNodeWindow(); }