public static bool Save(string prefKey, OptionIOData serializableObject) { MemoryStream memoryStream = new MemoryStream(); #if UNITY_IPHONE || UNITY_IOS System.Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes"); #endif BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(memoryStream, serializableObject); string tmp = System.Convert.ToBase64String(memoryStream.ToArray()); try { PlayerPrefs.SetString(prefKey, tmp); } catch (PlayerPrefsException) { return false; } return true; }
public void save() { OptionIOData opData = new OptionIOData(); audioMixer.GetFloat("MasterVolume", out opData.fMasterVol); opData.fMasterVol = Mathf.InverseLerp(-80, 0, opData.fMasterVol); audioMixer.GetFloat("MusicVolume", out opData.fBGMVol); opData.fBGMVol = Mathf.InverseLerp(-80, 0, opData.fBGMVol); audioMixer.GetFloat("SEVolume", out opData.fSEVol); opData.fSEVol = Mathf.InverseLerp(-80, 0, opData.fSEVol); opData.bGyroEnable = _appController.gyroEnable; save(opData); }
public void save(OptionIOData data) { // 保存用クラスにデータを格納. OptionIO.Save("OptionData", data); PlayerPrefs.Save(); }