private void LoadGameData() { var stream = File.OpenText("./Assets/Maps/map3.json"); string json = stream.ReadToEnd(); //Debug.Log(json); SongMap s = new SongMap(); JsonUtility.FromJsonOverwrite(json, s); this.song = new SongCondensed(s); foreach (float i in song.hitMap[KeyCode.Keypad1]) { Debug.Log(i); } //SongCondensed = new //setSong(new SongCondensed(SongMap.CreateFromJSON(json))); /* * // Path.Combine combines strings into a file path * // Application.StreamingAssets points to Assets/StreamingAssets in the Editor, and the StreamingAssets folder in a build * string filePath = Path.Combine(Application.streamingAssetsPath, "Maps/map1.json"); * * if (File.Exists(filePath)) * { * // Read the json from the file into a string * string dataAsJson = File.ReadAllText(filePath); * setSong(new SongCondensed(SongMap.CreateFromJSON(filePath))); * } * else * { * Debug.LogError("Cannot load game data!"); * } */ }
public void setSong(SongCondensed s) { song = s; }