/// <summary> /// 卸载某个bank , /// 注意bank 是有计数累计的,只有 计数累计 等于0 时才真正卸载 /// </summary> /// <param name="bankName"></param> public void UnLoadSoundBank(string bankName) { GameObject soundBankObj = null; if (!SoundNameAboutGameObject.ContainsKey(bankName)) { return; } soundBankObj = SoundNameAboutGameObject[bankName]; if (!GameObjectAboutBanks.ContainsKey(soundBankObj)) { return; } List<TAkBank> akBanks = GameObjectAboutBanks[soundBankObj]; if (akBanks.Count > 0) { TAkBank akBank = akBanks[0]; GameObject.Destroy(akBank); akBanks.RemoveAt(0); } if (akBanks.Count == 0) { GameObject.Destroy(soundBankObj); SoundNameAboutGameObject.Remove(bankName); } }
/// <summary> /// 加载bank /// </summary> /// <param name="bankName"></param> public void LoadSoundBank(string bankName, AkBank.VoidCompleted voidCompleted = null) { GameObject soundBankObj = null; if (!SoundNameAboutGameObject.ContainsKey(bankName)) { soundBankObj = new GameObject(string.Format("SoundBank_{0}", bankName)); soundBankObj.transform.SetParent(SoundBankObjRoot.transform, false); SoundNameAboutGameObject.Add(bankName, soundBankObj); } soundBankObj = SoundNameAboutGameObject[bankName]; soundBankObj.SetActive(false); TAkBank akBank = soundBankObj.AddComponent<TAkBank>(); akBank.Completed = voidCompleted; akBank.SetBankName(bankName); soundBankObj.SetActive(true); List<TAkBank> akBanks = null; if (!GameObjectAboutBanks.ContainsKey(soundBankObj)) { akBanks = new List<TAkBank>(); GameObjectAboutBanks.Add(soundBankObj, akBanks); } GameObjectAboutBanks[soundBankObj].Add(akBank); WWISE_FirstBankNameList.Add(bankName); }