//Save local values manually. //・To be saved value is only the 'key & value' pairs (Dictionary <string, string>). public void SavePrefs() { Dictionary <string, string> dic = items.ToDictionary(e => e.key, e => e.value.ToString()); //Duplicate key is not allowed. XPlayerPrefs.SetDictionary(SaveKey, dic); //compatible 'Param' class PlayerPrefs.Save(); }
//Set a software volume to PlayerPrefs (*) It does not affect the current software volume //外部からの設定保存(保存された PlayerPrefs のみ更新:現在の音量には影響しない) public void SetPrefs(Dictionary <string, int> pref) { if (pref != null && pref.Count > 0) { XPlayerPrefs.SetDictionary(SaveKey, pref); } }
/// <summary> /// Convert it to JSON format (string type) as a Dictionary and save it in PlayerPrefs ///(*) Param class is basically the same as a dictionary, and it is the same as XPlayerPrefs.SetDictionary(), because content classes (which inherit Dictionary) are handled easily. ///・In JSON, it is stored as a key array and value array (= XPlayerPrefs.TryGetArrayPair() can also be obtained as an array of pairs). /// /// 辞書として JSON 形式(文字列型)に変換して PlayerPrefs に保存する ///※Param は基本的に辞書と同じでパラメタを簡単に扱うクラス(Dictionary を継承している)ため、内容的には XPlayerPrefs.SetDictionary() と同じ。 ///・JSON ではキー配列と値配列として保存される(=TryGetArrayPair()でペアの配列としても取得できる)。 /// </summary> /// <param name="key">Save key</param> /// <param name="param">Save value (Param)</param> public static void SetPlayerPrefs(string key, Param param) { XPlayerPrefs.SetDictionary(key, param); }
//Save local values manually. //・To be saved value is only the 'key & value' pairs (Dictionary <string, string>). public void SavePrefs() { XPlayerPrefs.SetDictionary(SaveKey, GetValue()); //compatible 'Param' class PlayerPrefs.Save(); }