23 lines
582 B
C#
23 lines
582 B
C#
using System.IO;
|
|
using UnityEngine;
|
|
|
|
namespace Code.Saves
|
|
{
|
|
public static class SaveManager
|
|
{
|
|
private static string Path => Application.persistentDataPath + "/save.json";
|
|
|
|
public static void Save(GameData data)
|
|
{
|
|
var json = JsonUtility.ToJson(data, true);
|
|
File.WriteAllText(Path, json);
|
|
}
|
|
|
|
public static GameData Load()
|
|
{
|
|
if (!File.Exists(Path)) return new GameData();
|
|
var json = File.ReadAllText(Path);
|
|
return JsonUtility.FromJson<GameData>(json);
|
|
}
|
|
}
|
|
} |