Exemple #1
0
        /// <summary>
        /// 设置背景音乐
        /// </summary>
        /// <param name="bgmName">音乐名</param>
        public void SetBGM(string bgmName)
        {
            if (bgmName == mBGMName)
            {
                return;
            }
            if (string.IsNullOrEmpty(mBGMName) == false)
            {
                ResourceUtil.Unload(mBGMName);
            }

            mAudioSource.clip = ResourceUtil.Load <AudioClip>(bgmName);
            mAudioSource.Play();
        }
Exemple #2
0
 /// <summary>
 /// 播放一段声音
 /// </summary>
 /// <param name="soundName">声音名</param>
 public void PlaySound(string soundName, float volumn = 1f)
 {
     mAudioSource.PlayOneShot(ResourceUtil.Load <AudioClip>(soundName), volumn * this.volumn);
     ResourceUtil.Unload(soundName);
 }
Exemple #3
0
 /// <summary>
 /// 播放一段声音
 /// </summary>
 /// <param name="soundName">声音名</param>
 public void PlaySound(string soundName)
 {
     mAudioSource.PlayOneShot(ResourceUtil.Load <AudioClip>(soundName));
     ResourceUtil.Unload(soundName);
 }