Creating a loading bar

If your game involves some processor-intensive scenes, you may want to have a loading message appear when switching scenes. You can either do this by defining a scene in your project that acts as an "interim" scene that appears in between the proper scenes, or by creating a Menu that appears when the game is loading. You can also do both. In this tutorial, we'll create a "Loading" message that appears in the bottom-right corner of the screen, complete with a progress bar that shows how far through the loading process we are.

We'll start by enabling asynchronous loading, which will allow for a progress bar to be displayed. Towards the bottom of your Settings Manager, find the Scene loading section and check Load scenes asynchronously?.

In your Menu Manager, create a new Menu and name it Loading.

We want this Menu to appear only while the game is loading, so change it's Appear type to While Loading. We'll have it display in the lower-right corner, so change it's Postion to Aligned, and Alignment to Lower Right.

Though we could use a Unity UI for this Menu, in this tutorial we'll just use the internal AC menu system. To be able to preview our Menu as we build it, make sure you're in an AC scene and that Preview in Game Window? is checked at the top.

From the list of Element types beneath the Loading Menu's properties, choose Label and then click Add new. Name this Label as LoadingText.

Enter Loading... as the Label text, and style the text to your liking. It should look something like this in the Game window:

Now let's create a progress bar. From the same list of Element types, create a new Timer element, and name it ProgressBar.

Change the Timer type to Loading Progress, and assign AC's "white.png" texture as the Timer texture.

We need to scale this element horizontally to give it the same width as the label above it. Change it's Size to Manual, and increase the width (W) to something appropriate (in this example, 12.5 is a good value). Your Menu should now look like this:

This Menu will now appear when your game loads each scene. Note that you are not limited to using a Timer to display the loading progress. You can use your own display method, using custom code, and get the loading progress with the following function:

AC.KickStarter.sceneChanger.GetLoadingProgress ();

Descriptions of all functions available in SceneChanger - and all of AC's classes - are available in the Scripting guide.