public static void SaveDataDialog(Dialog _dialog, string _path) { DialogData data = new DialogData(_dialog); string completePath = _path; if (File.Exists(completePath)) { File.Delete(_path); AssetDatabase.Refresh(); } writer = new StreamWriter(_path, false); writer.Write(JsonUtility.ToJson(data)); writer.Close(); }
public DialogData(Dialog _editor) { dialogName = _editor.dialogName; tagNodes[0] = new DialogTagNodeData(_editor.BeginNode); tagNodes[1] = new DialogTagNodeData(_editor.EndNode); nodesData = new DialogNodeData[_editor.NodeList.Count]; for (int i = 0; i < _editor.NodeList.Count; i++) { nodesData[i] = new DialogNodeData(_editor.NodeList[i]); } subNodesData = new DialogData[_editor.SubDialogNodeList.Count]; posSubNodesData = new Vector2[_editor.SubDialogNodeList.Count]; connections = new string[_editor.SubDialogNodeList.Count]; for (int i = 0; i < _editor.SubDialogNodeList.Count; i++) { subNodesData[i] = new DialogData(_editor.SubDialogNodeList[i].dialog); } for (int i = 0; i < _editor.SubDialogNodeList.Count; i++) { posSubNodesData[i] = _editor.SubDialogNodeList[i].windowRect.position; if (_editor.SubDialogNodeList[i].connection is EndDialogTagNode) { connections[i] = "EndNode"; } else if (_editor.SubDialogNodeList[i].connection is SubDialogNode) { connections[i] = "SUB " + (_editor.SubDialogNodeList[i].connection as SubDialogNode).dialog.dialogName; } else { connections[i] = _editor.SubDialogNodeList[i].connection.windowTitle; } } }