// Use this for initialization
        private void Awake()
        {
            ApplyLocalize();    //Localize text

            //Load the software volume
            //保存された音量の読み込み
            Dictionary <string, int> pref = null;

            if (saveVolume)
            {
                pref = XPlayerPrefs.GetDictionary <string, int>(SaveKey);  //nothing -> null  //無いとき=null;
            }
            foreach (var item in items)
            {
                dic[item.key]         = item;        //Register in dictionary with key   //キーで辞書に登録
                initVolumes[item.key] = item.volume; //Save the value of inspector at startup  //起動時のインスペクタをデフォとする

                //Update stored saved volume    //保存された音量があったら更新
                if (pref != null && pref.ContainsKey(item.key))
                {
                    item.volume = pref[item.key];
                }

                SetVolume(item.key, item.volume);
            }
        }
 //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);
     }
 }
예제 #3
0
        //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();
        }
예제 #4
0
        // Use this for initialization
        private void Start()
        {
            //Load the software volume
            Dictionary <string, int> pref = null;

            if (saveVolume)
            {
                pref = XPlayerPrefs.GetDictionary <string, int>(SaveKey); //nothing -> null
            }
            foreach (var item in items)
            {
                dic[item.key]         = item;
                initVolumes[item.key] = item.volume;  //Save the value of inspector at startup

                if (pref != null && pref.ContainsKey(item.key))
                {
                    item.volume = pref[item.key];
                }

                SetVolume(item.key, item.volume);
            }
        }
예제 #5
0
 //Save local values manually.
 //・To be saved value is only checked state.
 public void SavePrefs()
 {
     XPlayerPrefs.SetBool(SaveCheckedKey, defaultChecked);
     PlayerPrefs.Save();
 }
예제 #6
0
 //Load local values manually.
 public void LoadPrefs()
 {
     defaultChecked = XPlayerPrefs.GetBool(SaveCheckedKey, defaultChecked);
 }
예제 #7
0
 //Save local values manually.
 //・To be saved value is only the 'isOn' state array.
 public void SavePrefs()
 {
     XPlayerPrefs.SetArray(SaveKey, IsOn);   //bool[]
     PlayerPrefs.Save();
 }
예제 #8
0
 //Load local values manually.
 public void LoadPrefs()
 {
     bool[] selected = XPlayerPrefs.GetArray(SaveKey, IsOn);
     SetOn(selected);
 }
예제 #9
0
        /// <summary>
        /// Generate and return elements saved in JSON format (string type) in PlayerPrefs as Param class.
        ///(*) Param class is basically the same as a dictionary, and it is the same as XPlayerPrefs.GetDictionary(), because content classes (which inherit Dictionary) are handled easily.
        ///・In JSON, the dictionary is also saved as a key array and a value array, so XPlayerPrefs.SetArrayPair() saved pair array can also be acquired as a dictionary.
        ///
        /// PlayerPrefs に JSON 形式(文字列型)で保存された要素を辞書として生成して返す
        ///※Param は基本的に辞書と同じでパラメタを簡単に扱うクラス(Dictionary を継承している)ため、内容的には XPlayerPrefs.GetDictionary() と同じ。
        ///・JSON では辞書もキー配列と値配列として保存されるため、XPlayerPrefs.SetArrayPair() 保存したペア配列も辞書として取得できる。
        /// </summary>
        /// <param name="key">Save key</param>
        /// <param name="def">Defalut value</param>
        /// <returns>Saved value (Param: newly created)</returns>
        public static Param GetPlayerPrefs(string key, Param def = null)
        {
            Dictionary <string, string> dic = XPlayerPrefs.GetDictionary <string, string>(key);

            return((dic != null) ? new Param(dic) : def);
        }
예제 #10
0
 /// <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);
 }
예제 #11
0
 //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();
 }