public void SaveData <T>(T userData, Version version, string filePath) where T : DataBase { if (null == userData) { Debug.LogError("Save data failed, user data is null"); return; } DataHolder <T> holder = new DataHolder <T>(version, DateTime.Now, userData); FileTools.WriteStringToFile(holder.Serialize(), filePath); }
public T LoadData <T>(string filePath) where T : DataBase { string saveDataFileContent; if (!FileTools.TryReadFileToString(filePath, out saveDataFileContent)) { return(null); } DataHolder <T> holder = new DataHolder <T>(); holder.Deserialize(saveDataFileContent); return(holder.UserData); }