public void Load <T>(string path, UnityAction <T, SaveResult, string> LoadCompleteMethod, bool encrypted) where T : class, new() { loadStatus = String.Empty; byte[] bytes = ReadFromFile <T>(path); if (bytes != null) { if (encrypted) { try { BinarySerializationUtility.DecryptData(ref bytes); } catch (Exception e) { loadStatus += "Decryption Error: " + e.Message; } } T deserializedData = new T(); try { deserializedData = JsonUtility.FromJson <T>(BinarySerializationUtility.GetString(bytes)); } catch (Exception e) { loadStatus += "Deserialization Error: " + e.Message; } if (loadStatus == String.Empty) { LoadCompleteMethod(deserializedData, SaveResult.Success, loadStatus); return; } } LoadCompleteMethod(null, SaveResult.Error, loadStatus); }
public void Load <T>(string path, UnityAction <T, SaveResult, string> LoadCompleteMethod, bool encrypted) where T : class, new() { byte[] bytes = ReadFromFile <T>(path); if (bytes != null) { if (encrypted) { BinarySerializationUtility.DecryptData(ref bytes); } LoadCompleteMethod(BinarySerializationUtility.DeserializeProperties <T>(bytes), SaveResult.Success, ""); return; } LoadCompleteMethod(new T(), SaveResult.Success, "File Was Created"); }