Exemple #1
0
        public void PlayBGM(string name, float volume)
        {
            if (!this.CanPlayBackSound())
            {
                return;
            }
            string audioClipPath = this.GetAudioClipPath(name, 0);

            if (this.bgm != null && this.bgm.path != audioClipPath)
            {
                this.bgm.Destory();
                this.bgm = null;
            }
            if (this.bgm == null)
            {
                this.bgm = new SoundManager.AudioData(audioClipPath, SoundManager.SoundType.BGM, true, this.SoundParent.transform, Vector3.zero, 128, 1f, 1f, (volume <= 1f) ? volume : 1f);
                base.StartCoroutine(Util.LoadBGMAudioAsync(this.bgm.go, audioClipPath, "ogg", delegate(AudioClip clip, string str)
                {
                    if (clip != null)
                    {
                        this.bgm.audio.clip   = clip;
                        this.bgm.audio.volume = volume;
                        this.bgm.Play(0f);
                    }
                }));
            }
            else
            {
                this.bgm.audio.volume = volume;
                if (!this.bgm.audio.isPlaying)
                {
                    this.bgm.Play(0f);
                }
            }
        }