예제 #1
0
    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.");
        }
    }
예제 #2
0
 private void OnApplicationQuit()
 {
     defaultData.CopyTo(liveData);
     defaultData.CopyTo(saveData);
 }