Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. 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

Continue playing Audio Track in next scene started from Timeline

Discussion in 'Timeline' started by jnbbender, May 14, 2020.

  1. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    367
    I have created an intro cutscene which at the end of the scene will trail off with my intense background music. Instead, I would like that music to continue to loop into my next loaded menu scene until the game is finally started. Is there a way to place the looped music into DontDestroyOnLoad to continue on? Any other solution?

    Thanks
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,497
    If you are using timeline, then one solution might be to move the timeline (or a separate timeline with just the audio) into a separate scene that you don't unload. If you start two timelines on the same frame, they will play in sync if they use the same clock (DSP, GameTime, etc...).

    You might be able to make a copy of the playable director object through script and have that persist as well, but I don't recall if/how to make it survive the scene unload. You might also have to duplicate all the bindings.

    The trick is you need to keep the PlayableDirector alive otherwise the PlayableGraph playing the timeline will be destroyed (which will cause the audio to stop), and the timeline asset and everything it references could be unloaded because it will no longer be referenced.
     
  3. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    367
unityunity