Problem with stopping a snapshot

Hello guys.
I’m constantly having problems with stopping a snapshot in my projects and I honestly fail to understand why.
I have a simple pause game situation where I pause the events and want to smooth it out with nice fades by applying a snapshot. The thing is starting the snapshot works, but stopping doesn’t, so after I unpause the game, the events still aren’t heard.

The code is:

private void PauseMusic(bool paused)
{   
    SoundEvent.setPaused(paused);
    BackgroundMusicSoundEvent.setPaused(paused); 

    if (paused)
    {
        SnapshotEvent = FMODUnity.RuntimeManager.CreateInstance("snapshot:/PauseGame");
        SnapshotEvent.start();
        isMusicPaused = true;
    }
    else 
    { 
        if (isMusicPaused)
        {
        SnapshotEvent.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
        SnapshotEvent.release();
        isMusicPaused = false;
        }
    }
}

and then I trigger the function like this:

if (currentPlayer.Pause.Active) PauseMusic(true);
else PauseMusic(false);

Any help, please? :slight_smile:

You seems to set pause on your events at the beginning and you never unpause them, or I am missing something?

I’m unpausing it here in the second line, by triggering the function with false argument:

if (currentPlayer.Pause.Active) PauseMusic(true);
else PauseMusic(false);

Overall, that else branch works, at least I’ve successfully tried Debug.Log there.

Sorry, I hadn’t realized setPaused was taking a bool parameter.

1 Like