Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Pausing Timeline Audio

Discussion in 'Timeline' started by Solovykh, Jul 25, 2019.

  1. Solovykh

    Solovykh

    Joined:
    Aug 28, 2017
    Posts:
    18
    Hey there,

    I'm implementing pause functionality in my game. AudioListener.pause doesn't pause timeline audio. Is the only way to pause audio tracks on a timeline that's running in game time to do:

    Code (CSharp):
    1. playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0);
    ?

    The problem I'm running into is that I have 100s of directors in my scene so keeping track of which ones are playing would be some overhead.

    Edit:

    It seems that code doesn't even work because it causes the audio track to stop playing before it's complete by the amount of time you had the experience paused for.

    Edit #2:
    I circumvented the bug in the first edit by caching the time using GetTime() on the director playable on pause and then using SetTime when I'm ready to unpause to restore the time. Not sure what this does.
     
    Last edited: Jul 26, 2019
  2. Solovykh

    Solovykh

    Joined:
    Aug 28, 2017
    Posts:
    18