浏览代码

Changed Game Save Manager root folder to Application.persistentDataPath

/main
Thomas ICHÉ 5 年前
当前提交
5118a548
共有 2 个文件被更改,包括 11 次插入5 次删除
  1. 6
      CHANGELOG.md
  2. 10
      Runtime/Managers/Implementations/GameSaveManager.cs

6
CHANGELOG.md


# Changelog
## 2019.3.4
#### Changed
* Game Save manager now saves to the Application.persistentDataPath folder
## 2019.3.3
#### Added

10
Runtime/Managers/Implementations/GameSaveManager.cs


[ManagerDefaultPrefab("GameSaveManager")]
public class GameSaveManager : Manager
{
[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 path where system and user saves will be stored. Relative to the Application.persistantDataPath folder.")]
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.")]

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

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

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

正在加载...
取消
保存