Tracking Progress

The progress of the loading the scene itself is tracked automatically. To track anything else that your game will need to load during the loading screen will have to be added manually. You can use the LoadingProgressTracker struct for this purpose.

Adding a Progress Tracker

Before you begin to load a scene, you can add multiple progress trackers.

The LoadingScreen.Instance.Load methods accepts an array of LoadingProgressTracker's as it's second parameter.

Step 1: Create a Float

Create a float field that will be updated as whatever it is you need to load progresses. Ensure that the reference to this field isn't lost due to a scene being unloaded.

private static float progress;

Step 2: Creating the Tracker

Create a LoadingProgressTracker that uses a getter so that it can get the value of the progress field as necessary.

The first parameter is the text displayed in the loading screen. The second parameter is the progress getter.

var process = new LoadingProgressTracker("Please wait...", () => progress);

Step 3: Adding the Tracker

This tracker can be added with the loading screen's Load method. You can't add a tracker while loading is ongoing, only before.

// Where sceneName is a string that contains the name of the scene you want to load
LoadingScreen.Instance.Load(sceneName, process);

Last updated