/// <summary> /// Save using different methods of writings /// </summary> /// <typeparam name="T">Type of Object to write</typeparam> /// <param name="save">Object of write</param> /// <param name="typesave">Type of writing method</param> /// <param name="path">path of the writing</param> /// <param name="option">option of differents methods : /// Binary/XML : Append if overwrinting /// Json : Pretty Writing in the file /// </param> protected void Save <T>(T save, TypeSave typesave, string path, bool option = false) { switch (typesave) { case TypeSave.Binary: DataWriteRead_Unity.WriteToBinaryFile(Application.persistentDataPath + "/" + path, save, option); break; case TypeSave.Json: Debug.Log("Sauvegarde en cours. " + Application.persistentDataPath + "/" + path); Debug.Log(Directory.GetCurrentDirectory()); DataWriteRead_Unity.WriteToJsonFile(Application.persistentDataPath + "/" + path, save, option); break; case TypeSave.XML: DataWriteRead_Unity.WriteToXmlFile(Application.persistentDataPath + "/" + path, save, option); break; } }
/// <summary> /// Load using different methods of loading /// </summary> /// <typeparam name="T">Type of object to load</typeparam> /// <param name="path">path of the loading</param> /// <param name="typesave">Type of loading method</param> /// <returns></returns> protected T Load <T>(string path, TypeSave typesave) { T res = default(T); switch (typesave) { case TypeSave.Binary: res = DataWriteRead_Unity.ReadFromBinaryFile <T>(Application.persistentDataPath + "/" + path); break; case TypeSave.Json: res = DataWriteRead_Unity.ReadFromJsonFile <T>(Application.persistentDataPath + "/" + path); break; case TypeSave.XML: res = DataWriteRead_Unity.ReadFromXmlFile <T>(Application.persistentDataPath + "/" + path); break; } return(res); }