浏览代码

Made paths and names alterable

/main
Thomas ICHÉ 6 年前
当前提交
5804a161
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 14
      Runtime/Managers/Implementations/GameSaveManager.cs

14
Runtime/Managers/Implementations/GameSaveManager.cs


[ManagerDefaultPrefab("GameSaveManager")]
public class GameSaveManager : Manager
{
private const string systemSaveName = "system.sav";
private const string userSaveName = "user{0}.sav";
[SerializeField, Tooltip("The path where system and user saves will be stored. Relative to the Executable_Data folder (or Assets folder for editor). Default is '/../' next to the executable or at the root of the project.")]
private string savePath = "/../";
[SerializeField, Tooltip("The file name of the System Save.")]
private string systemSaveName = "System.sav";
[SerializeField, Tooltip("The file format for a user save, use the {0} to specify where the numbering happens.")]
private string userSaveName = "User{0}.sav";
Dictionary<string, System.Object> systemSaveEntries;
Dictionary<string, System.Object> currentUserSaveEntries;

Dictionary<string, object> LoadFile(string fileName)
{
if(!File.Exists(Application.dataPath + "/../" + fileName))
if(!File.Exists(Application.dataPath + savePath + fileName))
{
SaveFile(fileName, new Dictionary<string, object>());
}

string contents= File.ReadAllText(Application.dataPath + "/../" + fileName);
string contents= File.ReadAllText(Application.dataPath + savePath + fileName);
SerializableOutput data = JsonUtility.FromJson<SerializableOutput>(contents);

i++;
}
File.WriteAllText(Application.dataPath + "/../" + filename, JsonUtility.ToJson(data));
File.WriteAllText(Application.dataPath + savePath + filename, JsonUtility.ToJson(data));
}
[System.Serializable]

正在加载...
取消
保存