示例#1
0
        /// <summary>
        /// Saves the time.
        /// </summary>
        public void SaveTime()
        {
            // Create a new Time_Data.
            Time_Data data = new Time_Data();

            // Store our precious information.
            data.hour   = currentTimeHour;
            data.minute = currentTimeMinute;
            data.second = currentTimeSecond;
            // Turn this precious information into precious JSON information.
            string timeToJson = JsonUtility.ToJson(data);

            // Save the encrypted precious JSON information.
            PlayerPrefs.SetString("GameTime", timeToJson);
        }
示例#2
0
        /// <summary>
        /// Loads the time.
        /// </summary>
        public void LoadTime()
        {
            // Get the saved encrypted information.
            string keyJson = PlayerPrefs.GetString("GameTime");

            // If we have a null or empty string.
            if (String.IsNullOrEmpty(keyJson))
            {
                // We do nothing.
                return;
            }
            // Cast our Json data to Key_Data.
            Time_Data data = JsonUtility.FromJson <Time_Data> (keyJson);

            currentTimeHour   = data.hour;
            currentTimeMinute = data.minute;
            currentTimeSecond = data.second;
        }