private void Save(string saveName) { var data = new NodeTreeEditorData { Name = _menuBar.NodeTreeName, StartNode = _startNode.Save(_mediaType), Nodes = _nodes.Select(x => x.Save(_mediaType)).ToList(), Connections = _connections.Select(x => x.Save(_mediaType)).ToList(), Zoom = _zoom }; File.WriteAllText(Application.dataPath + "/Resources/NodeTrees/" + saveName + ".vn", _mediaType.ConvertTo(data)); _vnSaver.Save(data, saveName); }
public void Save(NodeTreeEditorData data, string saveName) { Debug.Log($"{data.Nodes.Count}"); var connections = data.Connections.Select(x => _mediaType.ConvertFrom <ConnectionData>(x)).ToList(); data.Nodes .ForEach(oNode => oNode.NodeData.NextIds = data.Nodes .Where(xNode => connections.Any(connection => connection.OutNodeID == oNode.NodeData.Id && connection.InNodeID == xNode.NodeData.Id)) .OrderBy(x => x.X) .Select(x => x.NodeData.Id) .ToList()); _storage.Put(saveName, new NodeTreeData { StartIds = connections.Where(x => x.OutNodeID == _mediaType.ConvertFrom <StartNodeData>(data.StartNode).ID).Select(x => x.InNodeID).ToArray(), Nodes = data.Nodes.Select(x => x.NodeData).ToArray() }); }