Пример #1
0
 public void PlayBGM(BGMSound bgm)
 {
     BGMSoundEvent.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
     BGMSoundEvent = FMODUnity.RuntimeManager.CreateInstance(BGMSounds[(int)bgm]);
     FMODUnity.RuntimeManager.AttachInstanceToGameObject(BGMSoundEvent, GetComponent <Transform>(), GetComponent <Rigidbody>());
     BGMSoundEvent.start();
 }
    public void Stop(string name)
    {
        BGMSound s = Array.Find(sounds, sound => sound.name == name);

        if (s == null)
        {
            Debug.LogWarning("Sound: " + name + " not found!");
            return;
        }

        s.source.Stop();
    }
Пример #3
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Пример #4
0
        public void BGMChangePlay(BGMSound bgmSound, float volume = 1f, float changeSpeed = 1f, float waitTime = 1f, float maxTime = 1f, bool isSmooth = false)
        {
            if (BGMClips.Length <= 0 || BGMClips.Length <= (int)bgmSound)
            {
                return;
            }

            time = RealTime.time;
            if (sourceBgm.clip == BGMClips[(int)bgmSound] && mLastTimestamp + 0.1f > time)
            {
                return;
            }
            mLastTimestamp = time;

            AudioClip changeClip = BGMClips[(int)bgmSound];

            if (!isSmooth)
            {
                BGMPlay(changeClip, volume);
                return;
            }

            StartCoroutine(Co_BGMChangePlay(changeClip, volume, changeSpeed, waitTime, maxTime));
        }