예제 #1
0
        /// <summary>
        /// Persists the high scores into the player prefs
        /// </summary>
        private void SerializeHighScores()
        {
            HighScoresContainer container = new HighScoresContainer
            {
                HighScores = HighScores
            };

            string json = JsonUtility.ToJson(container);

            PlayerPrefs.SetString(mPlayerPrefsHighScoresKey, json);
        }
예제 #2
0
        /// <summary>
        /// Retrieves the high scores from player prefs
        /// </summary>
        private void DeserializeHighScores()
        {
            string json = PlayerPrefs.GetString(mPlayerPrefsHighScoresKey, "");

            if (string.IsNullOrEmpty(json))
            {
                HighScores = new List <HighScore>();
                return;
            }

            HighScoresContainer container = JsonUtility.FromJson <HighScoresContainer>(json);

            HighScores = container.HighScores;
        }