コード例 #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
ファイル: PlayerStats.cs プロジェクト: GameDiffs/TheForest
 private static void StopIfPlaying(FMOD.Studio.EventInstance evt)
 {
     if (evt == null)
     {
         return;
     }
     PLAYBACK_STATE pLAYBACK_STATE;
     UnityUtil.ERRCHECK(evt.getPlaybackState(out pLAYBACK_STATE));
     if (pLAYBACK_STATE != PLAYBACK_STATE.STOPPING && pLAYBACK_STATE != PLAYBACK_STATE.STOPPED)
     {
         UnityUtil.ERRCHECK(evt.stop(STOP_MODE.ALLOWFADEOUT));
     }
 }
コード例 #3
0
    public void StopSound(FMOD.Studio.EventInstance fmodEvent, FMOD.Studio.STOP_MODE stopMode)
    {
        if (fmodEvent == null)
        {
            Debug.LogError("ERROR! Audio missing.");
            return;
        }

        if (mPlayingSoundEvents.Remove (fmodEvent) && mDebug)
        {
            printSound();
        }
        fmodEvent.stop(stopMode);
    }