private void InitAudio() { //初始化的时候,去获取音源组件 audioSource = GameTool.GetTheChildComponent <AudioSource>(this.gameObject, "AudioManager"); if (!GameTool.HasKey("AudioValue")) { GameTool.SetFloat("AudioValue", 0.5f); audioValue = 0.5f; } else { audioValue = GameTool.GetFloat("AudioValue"); audioSource.volume = audioValue; } if (!GameTool.HasKey("Mute")) { GameTool.SetString("Mute", "false"); isMute = false; } else { isMute = bool.Parse(GameTool.GetString("Mute")); audioSource.mute = isMute; } }
public void SetMute(bool isMute) { this.isMute = isMute; //把外界传进来的值设置给组件 audioSource.mute = isMute; //把最新的值存储到内存中 GameTool.SetString("Mute", isMute.ToString()); }
//初始化背包数据的方法 public void InitData() { // GameTool.DeleteAll();//测试用 if (!GameTool.HasKey("PackData")) { GameTool.SetString("PackData", "1'0;2'30;3'10;4'20;5'60;6'0;7'0;8'0;9'0;10'0;11'0;12'0;13'0;14'0;15'0;16'0;17'0;18'0;19'0;20'0;21'0;22'0"); } string data = GameTool.GetString("PackData"); string[] arrData = data.Split(';'); ToDictionary(arrData); }
private void SaveData() { int index = 0; string strData = ""; Dictionary <int, int> .KeyCollection allKey = packDataDic.Keys; foreach (int key in allKey) { index++; strData += key + "'" + packDataDic[key]; if (index != packDataDic.Count) { strData += ";"; } } GameTool.SetString("PackData", strData); }