Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Pausing Timeline Audio

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

  1. Solovykh

    Solovykh

    Joined:
    Aug 28, 2017
    Posts:
    59
    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:
    59
unityunity