private void Load() { var nodesDeserialized = XMLOp.Deserialize <List <Node> >("Assets/Resources/nodes.xml"); var connectionsDeserialized = XMLOp.Deserialize <List <Connection> >("Assets/Resources/connections.xml"); nodes = new List <Node>(); connections = new List <Connection>(); foreach (var nodeDeserialized in nodesDeserialized) { nodes.Add(new Node( position: nodeDeserialized.rect.position, width: nodeDeserialized.rect.width, height: nodeDeserialized.rect.height, nodeStyle: nodeStyle, selectedStyle: selectedNodeStyle, inPointStyle: inPointStyle, outPointStyle: outPointStyle, onClickInPoint: OnClickInPoint, onClickOutPoint: OnClickOutPoint, onClickRemoveNode: OnClickRemoveNode, inPointId: nodeDeserialized.inPoint.id, outPointId: nodeDeserialized.outPoint.id ) ); } foreach (var connectionDeserialized in connectionsDeserialized) { var inPoint = nodes.First(n => n.inPoint.id == connectionDeserialized.inPoint.id).inPoint; var outPoint = nodes.First(n => n.outPoint.id == connectionDeserialized.outPoint.id).outPoint; connections.Add(new Connection(inPoint: inPoint, outPoint: outPoint, onClickRemoveConnection: OnClickRemoveConnection)); } }
private void Save() { XMLOp.Serialize(item: nodes, path: "Assets/Resources/nodes.xml"); XMLOp.Serialize(item: connections, path: "Assets/Resources/connections.xml"); }