/// <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 int?GetExistingWorldVariableIntValue(string variableName, int startingValue) { var tokenKey = InGameWorldVariable.GetTokenPrefsKey(variableName); // save this if we need it later. if (!VariableExistsInScene(variableName)) { return(null); } if (!PlayerPrefs.HasKey(tokenKey)) { // set it if this is the first time!! PlayerPrefs.SetInt(tokenKey, startingValue); } return(PlayerPrefs.GetInt(tokenKey)); }