diff --git a/Assets/Scripts/Buttons/SaveButton.cs b/Assets/Scripts/Buttons/SaveButton.cs index b6434f0..1619830 100644 --- a/Assets/Scripts/Buttons/SaveButton.cs +++ b/Assets/Scripts/Buttons/SaveButton.cs @@ -3,6 +3,9 @@ using UnityEngine; using UnityEngine.EventSystems; using System; +using UnityEditor; +using System.IO; +using System.Text; public class SaveButton : MonoBehaviour, IPointerDownHandler { public Config config; @@ -49,6 +52,12 @@ SaveStruct save = new SaveStruct(); save.nodes = nodes; save.roads = roads; - print(JsonUtility.ToJson(save)); + string jsonData = JsonUtility.ToJson(save); + string filePath = EditorUtility.SaveFilePanel("Save current road network", "", + "untiteledIntersection.json", "json"); + if (filePath.Length == 0) { + return; + } + File.WriteAllBytes(filePath, Encoding.ASCII.GetBytes(jsonData)); } }