private void LoadGameData() { bool loadReturn = false; GameData loadData = new GameData(); if (Application.platform == RuntimePlatform.WebGLPlayer) { loadData.distance = PlayerPrefs.GetFloat("distance", defaultData.gameData.distance); loadData.coin = PlayerPrefs.GetInt("coin", defaultData.gameData.coin); loadReturn = true; } else { int loadTry = 0; while (!loadReturn && loadTry < maxLoadRetry) { try { loadData = SaveLoadManager.Load("GameData") as GameData; if (loadData == null) { loadData = new GameData(); loadData.distance = defaultData.gameData.distance; loadData.coin = defaultData.gameData.coin; } loadReturn = true; } catch { loadReturn = false; } loadTry++; } } if (loadReturn) { saveData.gameData = loadData; saveData.CopyTo(liveData); Debug.LogWarning("Data Load Success."); } else { Debug.LogError("Data Load Fail."); } }
private void OnApplicationQuit() { defaultData.CopyTo(liveData); defaultData.CopyTo(saveData); }