public static Profile LoadProfile() { var encrypting = MainGameManager.Instance.usingEncryption; var startTime = DateTime.UtcNow; string profilePath = Path.Combine(Application.persistentDataPath, ConstantsResourcesPath.FILE_PROFILE); Debug.Log("[GLOBAL.PROFILE] Starting load profile: " + profilePath); if (File.Exists(profilePath + ".json")) { string json = File.ReadAllText(profilePath + ".json"); try { //Дешифруем if (encrypting) { json = SimpleEncrypting.Decode(json); } Debug.Log("[GLOBAL.PROFILE] Load profile complete"); Debug.Log("[GLOBAL.PROFILE] TOTAL TIME (ms): " + (DateTime.UtcNow - startTime).TotalMilliseconds); return(JsonUtility.FromJson <Profile>(json)); } catch { Debug.LogError("<color=#FF0000>[GLOBAL.PROFILE] File failed to decrypt! Profile is delete</color>"); File.Delete(profilePath + ".json"); return(LoadProfile()); } } else { Profile profile = new Profile(); profile.ApplyDefaultSettings(); Debug.LogWarning("<color=#FF0000>[GLOBAL.PROFILE] File not found. Apply default profile</color>"); Debug.Log("[GLOBAL.PROFILE] TOTAL TIME (ms): " + (DateTime.UtcNow - startTime).TotalMilliseconds); return(profile); } }
private void OnDecode() { //Дешифруем secondData = SimpleEncrypting.Decode(firstData); }