/*! \endcond */

        /// <summary>
        /// This method will flush all World Variable values and write them to a text file for later retrieval. Normally not needed. If you find your variable values get lost, call this before changing Scenes. I've never seen it happen myself.
        /// </summary>
        public static void FlushAll()
        {
#if UNITY_WEBPLAYER || UNITY_WP8 || UNITY_METRO || UNITY_WIIU
            // can't compile this class
#else
            PlayerPrefs.Flush();
#endif
        }
        /// <summary>
        /// Gets the existing world variable value. This should only be used in startup code. Otherwise grab the variable from GetWorldVariable
        /// </summary>
        /// <returns>
        /// The existing World Variable value in PlayerPrefs.
        /// </returns>
        /// <param name='variableName'>World Variable name.</param>
        /// <param name="startingValue">The value to use if not present.</param>
        public static float?GetExistingWorldVariableFloatValue(string variableName, float startingValue)
        {
            var tokenKey = InGameWorldVariable.GetTokenPrefsKey(variableName);

            // save this if we need it later.
            if (!VariableExistsInScene(variableName))
            {
                return(null);
            }

            if (!PlayerPrefs.HasKey(tokenKey))
            {
                // if this is the first time, set it!
                PlayerPrefs.SetFloat(tokenKey, startingValue);
            }

            return(PlayerPrefs.GetFloat(tokenKey));
        }
Exemple #3
0
 void OnDisable()
 {
     PlayerPrefs.Flush();
 }
Exemple #4
0
 void OnEnable()
 {
     PlayerPrefs.Flush();
 }
Exemple #5
0
 public void Remove(string id)
 {
     PlayerPrefs.DeleteKey(id);
 }
Exemple #6
0
 public bool Exists(string id)
 {
     return(PlayerPrefs.HasKey(id));
 }
Exemple #7
0
 public string Get(string id)
 {
     return(PlayerPrefs.GetString(id, string.Empty));
 }
Exemple #8
0
 public void Set(string id, string val)
 {
     PlayerPrefs.SetString(id, val);
 }
Exemple #9
0
 public int GetInt(string id)
 {
     return(PlayerPrefs.GetInt(id, 0));
 }
Exemple #10
0
 public void SetInt(string id, int val)
 {
     PlayerPrefs.SetInt(id, val);
 }
Exemple #11
0
 public void Save()
 {
     PlayerPrefs.Flush();
 }