Skip to main content
Version: 4.0.0 🚧

Creating Loading Screens

During scene transitions, you have the option to provide an intermediate scene that can be used as loading screen. This could be an animated splash screen or a loading progress bar, for example. This package provides implementations to help you build your loading screens faster.

Loading Screen Example​

Take the following loading screen scene hierarchy as an example:

By having this hierarchy in your loading scene, it would be able to fade in/out and display both the loading progress bar and loading progress text feedback. As this scene has the LoadingFader component, remember to enable both WaitForScriptedStart and WaitForScriptedEnd toggles in the LoadingBehavior component.

You can test this scene by passing its ILoadSceneInfo reference as the intermediateSceneInfo parameter in an ISceneLoader.TransitionToScene method.

Loading Components​

The Loading Behavior​

The Loading Behavior is a MonoBehaviour component, which you can attach to Unity GameObjects, that receives the progress value from the scene manager. You need to add a LoadingBehavior component to a GameObject in your loading scene to be able to display scene loading feedback. It exposes its LoadingProgress instance, which you can use to listen to the loading events:

public class LoadingProgress : IProgress<float>
{
public event Action<float> Progressed;
public event Action LoadingCompleted;
}

The LoadingCompleted event notifies when the scene load operation is completed, but the loading scene is still active. The Progressed event sends a float parameter, ranging from 0 to 1, to report the progress of the scene loading operation.

Back to the LoadingBehavior, it has a few options you can set on the Unity Inspector:

  • Wait For Scripted Start: enable if the loading screen will have a transition in effect, such as a fade in.
  • Wait For Scripted End: enable if the loading screen will have a transition out effect, such as a fade out.

You will use these controls to customize your loading screen behavior.

The Loading Feedback​

At this point, you should already have your loading scene with a LoadingBehavior attached to one of your GameObjects. Now you can also add some other components to display the loading progress feedback. This package comes with three feedbacks:

  • LoadingFeedbackSlider: attach on an UI Slider to display the loading progress feedback as a progress bar.
  • LoadingFeedbackTextMeshPro: attach on an UI Text Mesh Pro to display the loading progress feedback as text normalized from 0 to 100.
  • LoadingFeedbackText (also known as Legacy): attach on an UI Legacy Text to display the loading progress feedback as text normalized from 0 to 100.

You can use a combination of these feedback components in the loading scene. Remember to assign the LoadingBehavior field of these components to the LoadingBehavior component you created before.

Loading Fader​

The LoadingFader component performs fade in/out transitions. Add it to an UI Canvas Group GameObject to control the group's alpha value during the visual transitions. You can also set the fade time and customize the fade in/out animation curves to suit your preference.

To use the LoadingFader effectively, you must enable both WaitForScriptedStart and WaitForScriptedEnd toggles in your LoadingBehavior component.

Loading Scene Sample​

You can try multiple loading scenes in the Loading Scene Examples Sample.