コード例 #1
0
ファイル: SoundComponentSystem.cs プロジェクト: 526077247/ET
        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;
            }
        }
コード例 #2
0
ファイル: SoundComponentSystem.cs プロジェクト: 526077247/ET
        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);
        }