Delaying LoadScene while Cinematic Sequence Plays in Unity 2021

Above we can see the desired end result for my start menu screen.

When the player clicks the “Start Demo” button, I want it to load the in-game scene of the demo, AFTER, I play a Timeline sequence.

Shown above is the normal SceneManager.LoadSceneAsync statement we generally use.

The issue is that the code above runs like this:

The new scene loads as quickly as the user device can process it, skipping the beautiful timeline scene I’ve put together!

So, how do we fix this?

We make use of AsyncOperation.allowSceneActivation and a coroutine!

The LoadDemoScene() method is fired when the player clicks the start button.

It then turns on my Timline director game object and starts a coroutine for loading the scene.

Here, we set .allowSceneActivation to false immediately after calling LoadSceneAsync.

In typical coroutine fashion, we use WaitForSeconds() and then set our .allowSceneActivation back to true.

Once again, as shown at the beginning of this article, we can see our scene loading behavior working as desired!

That’s it, enjoy!

Remember to unload the original scene once you’ve loaded into the new scene.
Use the start() method on a script that is active/enabled as soon as the new scene loads and plug the code shown above into it.

It’s also worth noting, we could use signal emitters on the timeline itself to trigger a loadscene method on our script at the appropriate time, but I think this way gives the game engine time to do its async operations while the cinematic plays and thus be smoother in the final built game demo.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store