Execute script when scene is visible to player

Hi all

When using scenemanager I am having differences between editor and device. I have a singleton game manager which sets up some logic and then loads next scene which is the menu scene.

On that menu scene I have a countdown script which starts at 10 down to 1. This is hooked up to a Unity UI text control and updates the correct count in the editor as expected.

However, when I check on a device the menu scene loads but there is a bigger delay and by the time I can see the new scene the countdown is already down to 4.

How can I consistently manage the transition so that I only start scripts / animations when visible to cater for the different loading speeds and behaviours between hardware?

I have tried scenemanager.loadsceneasync as well as AsyncOperation such as allowSceneActivation to false as well as checking isDone and none have the desired effect. Also OnLevelWasLoaded has an unpredictable execution order.

What would you suggest for a true “is visible to user” and “is fully loaded” check to kick off these scripts?

I believe the counter shouldn’t start until allowSceneActivation is set to true unless the counter logic is on the Singleton rather than an object of the newly loaded scene…

Do you do any sort of visual transition? At the end of a fade or something could be a good time to activate the counter.