public void Connect(NodeConnectionData connectionData) { var sourcePin = Helper.GetPin(connectionData.SourceNodeId, connectionData.SourcePinId); var targetPin = Helper.GetPin(connectionData.TargetNodeId, connectionData.TargetPinId); Connect(new NodeConnection(sourcePin, targetPin)); }
public static NodeGraphData GetGraphData(NodeGraph graph) { NodeEditor.Logger.Log <NodeGraphState>("Serializing graph state..."); var outGraphData = new NodeGraphData(); outGraphData.GraphType = graph.GraphType.GetType().ToString(); // TODO: Find a nicer way to do this... graph.Nodes.ForEach(node => { if (node.GetType() == typeof(NodeConstant)) { outGraphData.Constants.Add(NodeConstantData.Convert(node as NodeConstant)); } else if (node.GetType() == typeof(NodeVariable)) { outGraphData.VariableNodes.Add(NodeVariableData.Convert(node as NodeVariable)); } else { outGraphData.Nodes.Add(NodeData.Convert(node)); } }); graph.Connections.ForEach(connection => outGraphData.Connections.Add(NodeConnectionData.Convert(connection))); graph.Variables.ForEach(variable => outGraphData.Variables.Add(NodeGraphVariableData.Convert(variable))); return(outGraphData); }