private static async ETTask CoPlayMusic(this SoundComponent self, string name, bool force) { Log.Info("CoPlayMusic"); if (!force && self.CurMusic == name) { return; } SoundManager.Instance.m_bgm.loop = true; AudioClip ac = self.Get(name); if (ac == null) { ac = await AddressablesManager.Instance.LoadAssetAsync <AudioClip>(name); if (ac != null) { self.Add(name, ac); SoundManager.Instance.m_bgm.clip = ac; SoundManager.Instance.m_bgm.Play(); self.CurMusic = name; } else { Log.Info("ac is null"); } } else { SoundManager.Instance.m_bgm.clip = ac; SoundManager.Instance.m_bgm.Play(); self.CurMusic = name; } }
private static async ETTask PoolPlay(this SoundComponent self, string name) { AudioClip clip = self.Get(name); if (clip == null) { clip = await AddressablesManager.Instance.LoadAssetAsync <AudioClip>(name); if (clip == null) { // Debug.Log("clip is null"); return; } } AudioSource source = self.GetClipSource(); source.clip = clip; source.Play(); await TimerComponent.Instance.WaitAsync((long)(clip.length * 1000) + 100); source.gameObject.SetActive(false); }