Splash Screen does not execute script code in background?

I have a question regarding the Unity splash screen.

I assumed Unity loads and awakes the first scene in “Scenes in Build” list, while the splash screen is displayed.

However, it seems Unity loads/awakes the scene after the splash screen was displayed.

I configured the splash screen to last 10 seconds and added the following script to the first scene:

public class First : MonoBehaviour
{
    void Awake()
    {
        Debug.LogFormat("First.Awake: time={0}", Time.realtimeSinceStartup);
    }

    void Start()
    {
        Debug.LogFormat("First.Start: time={0}", Time.realtimeSinceStartup);
    }

    void Update()
    {
        if (UnityEngine.Rendering.SplashScreen.isFinished)
        {
            Debug.LogFormat("First.Update: SplashFinished={0}, time={1}", UnityEngine.Rendering.SplashScreen.isFinished, Time.realtimeSinceStartup);
            this.enabled = false;
        }
    }
}

All these Log’s come pretty much at the same time.

09-17 15:09:11.881 18359 18372 D Unity   : OPENGL LOG: Creating OpenGL ES 3.0 graphics device ; Context level  <OpenGL ES 3.0> ; Context handle -1200478448
09-17 15:09:11.884 18359 18372 D Unity   : [EGL] Attaching window :0xb8361818
09-17 15:09:11.893 18359 18372 D Unity   : Requested framebuffer: resolution[1280x800], rgba[8/8/8/8], depth+stencil[on], samples[1]
09-17 15:09:11.893 18359 18372 D Unity   : Created framebuffer: resolution[1280x800], rgba[8/8/8/8], depth+stencil[24/8], samples[0]
09-17 15:09:11.894 18359 18372 D Unity   : [EGL] Attaching window :0xb8361818
09-17 15:09:11.895 18359 18372 D Unity   : Initialize engine version: 2018.4.4f1 (5440768ff61c)
09-17 15:09:11.932 18359 18372 D Unity   : Begin MonoManager ReloadAssembly
09-17 15:09:12.818 18359 18372 D Unity   : - Completed reload, in  0.886 seconds
09-17 15:09:13.148 18359 18372 D Unity   : PlayerInitEngineGraphics OK
09-17 15:09:13.153 18359 18372 D Unity   : Found 7 native sensors
09-17 15:09:13.156 18359 18372 D Unity   : Sensor :        Accelerometer ( 1) ; 0.010000 / 0.00s ; kxtj9-accel / Kionix
09-17 15:09:13.159 18359 18372 D Unity   : Sensor :        Accelerometer ( 1) ; 0.010000 / 0.00s ; kxtj9-accel / Kionix
09-17 15:09:13.176 18359 18372 D Unity   : SetWindow 0 0xb83fe850
09-17 15:09:13.176 18359 18372 D Unity   : [EGL] Attaching window :0xb83fe850
09-17 15:09:13.193 18359 18372 D Unity   : ANativeWindow: (1280/800) RequestedResolution: (0/0) RenderingResolution: (0/0) EGLSurface: (1280/800)
09-17 15:09:23.340 18359 18372 D Unity   : UnloadTime: 13.021000 ms
09-17 15:09:23.356 18359 18372 D Unity   : UUID: xxx
09-17 15:09:23.827 18359 18372 I Unity   : First.Awake: time=10.12555
09-17 15:09:23.827 18359 18372 I Unity   :
09-17 15:09:23.866 18359 18372 D Unity   : Sensor :        Accelerometer ( 1) ; 0.010000 / 0.00s ; kxtj9-accel / Kionix
09-17 15:09:23.875 18359 18372 D Unity   : Choreographer available: Enabling VSYNC timing
09-17 15:09:23.897 18359 18372 I Unity   : First.Start: time=10.63175
09-17 15:09:23.897 18359 18372 I Unity   :
09-17 15:09:24.001 18359 18421 D Unity   : Setting up 1 worker threads for Enlighten.
09-17 15:09:24.006 18359 18422 D Unity   :   Thread -> id: ffffffff9bc9b930 -> priority: 1
09-17 15:09:24.377 18359 18372 I Unity   : First.Update: SplashFinished=True, time=11.10229
09-17 15:09:24.377 18359 18372 I Unity   :
09-17 15:09:30.532 18359 18359 I Unity   : windowFocusChanged: false
09-17 15:09:30.590 18359 18359 I Unity   : onPause
09-17 15:09:30.692 18359 18372 D Unity   : Sensor :        Accelerometer ( 1) ; 0.010000 / 0.00s ; kxtj9-accel / Kionix
09-17 15:09:30.726 18359 18372 D Unity   : SetWindow 0 0x0

I assumed Awake() and Start() would be called about the same time the splash screen appears, but they are called after 10secs, when the splash screen finished.

I want to execute code during the splash screen to async load further scenes to minimize loading times to the first interactible scene.

Tested with Unity 2018.4.1f1 on Android and Windows Standalone.

4971956–484352–splashscreen_problem.zip (23.3 KB)

@karl_jones If I remember correctly, you worked on the splash screen feature. Is this is the expected behavior?

Yes, I wrote the current splash.
No, we don’t execute any code during the splash, this is by design.
We load the scene in the background while the splash is displayed but we do not activate or run the main player loop until we do the final fade which lasts around 0.3 secs. We don’t want to get into a situation where the game is running in the background but the splash is still visible and blocking the view. There is an API to draw the splash manually so you could do something like this:

1: Disable the splash
2: Load an empty scene as the first scene.
3: Call the Splash API in the empty scene and do loading/init Unity - Scripting API: SplashScreen

The advantage of this is you can then let users press any key to quit the splash when you are ready

1 Like

Thanks for the quick reply and help Karl!

My current workaround works actually pretty good, I just wanted to clarify whether the current implemented splash behavior is by design.

Using a custom splash screen was a great way to significantly reduce the time to reach the first interactive screen in our game, since we can use the splash time to load and initialize stuff in the background.

1 Like