예제 #1
0
        // Starts or stops a looping audio event depending on whether the play condition is met
        // Prevents retriggering when play should be continuous
        public static void startStopLoop(FMOD.Studio.EventInstance loopingSound, Boolean playConditionMet, GameObject soundSource)
        {
            var attributes = FMOD.Studio.UnityUtil.to3DAttributes(soundSource.transform.position);
            loopingSound.set3DAttributes(attributes);
            FMOD.Studio.PLAYBACK_STATE state;
            loopingSound.getPlaybackState(out state);

            // Stop looping sound if already playing and play condition is no longer true
            if (state == PLAYBACK_STATE.PLAYING)
            {
                if (!playConditionMet)
                {
                    loopingSound.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                }
            }
            // Start looping sound if play condition is met and sound not already playing
            else
            {
                if(playConditionMet)
                {
                    loopingSound.start();
                }
            }
        }
예제 #2
0
 private static void StartIfNotPlaying(FMOD.Studio.EventInstance evt)
 {
     if (evt == null)
     {
         return;
     }
     PLAYBACK_STATE pLAYBACK_STATE;
     UnityUtil.ERRCHECK(evt.getPlaybackState(out pLAYBACK_STATE));
     if (pLAYBACK_STATE != PLAYBACK_STATE.STARTING && pLAYBACK_STATE != PLAYBACK_STATE.PLAYING)
     {
         UnityUtil.ERRCHECK(evt.start());
     }
 }
예제 #3
0
    void StartSound(FMOD.Studio.EventInstance fmodEvent)
    {
        if (mMuteMaster || mMuteSounds)
        {
            return;
        }

        fmodEvent.setPitch (Time.timeScale);
        fmodEvent.setVolume(mMasterLevel * mSoundsLevel);
        fmodEvent.start();
    }