private static void ConstructGraphFromSaveData(SaveData saveData, out List<NodeGUI> nodes, out List<ConnectionGUI> connections)
{
var currentNodes = new List<NodeGUI>();
var currentConnections = new List<ConnectionGUI>();
foreach (var node in saveData.Nodes) {
var newNodeGUI = new NodeGUI(node);
newNodeGUI.WindowId = GetSafeWindowId(currentNodes);
currentNodes.Add(newNodeGUI);
}
// load connections
foreach (var c in saveData.Connections) {
var startNode = currentNodes.Find(node => node.Id == c.FromNodeId);
if (startNode == null) {
continue;
}
var endNode = currentNodes.Find(node => node.Id == c.ToNodeId);
if (endNode == null) {
continue;
}
var startPoint = startNode.Data.FindConnectionPoint (c.FromNodeConnectionPointId);
var endPoint = endNode.Data.FindConnectionPoint (c.ToNodeConnectionPointId);
currentConnections.Add(ConnectionGUI.LoadConnection(c.Label, c.Id, startPoint, endPoint));
}
nodes = currentNodes;
connections = currentConnections;
}