Unity 5.0 Progress bar for scene loading JS

Hello

I need simple example unity script code for unity 5 progress bar for scene loading.
I see this links and couldn’t find the answer and also watch some old tutorials but couldn’t understand any thing :frowning:

thanks in advance

Hi,

**As @hoekkii said, you can have the progress of LoadLevelAsync with Unity - Scripting API: AsyncOperation.progress **

So now we have a float between 0 and 1.0f or 0 and 100.0f i guess and that’s a good start !


Now there are like thousands of techniques for a loading bar ! Based on the progress float you can, fill an image, instantiate little cubes, plays different noises, turn up the volume …

Let’s focus on the classical one, the bar that fills up.

In a canvas add an image. Its type should be simple right now, change it to filled and adjust the parameters:

  • Fill method: Horizontal
  • Fill origin: Left
  • Fill amount: 0

Now with a script attached to the image, in the Update() function, make the fill amount equal to the progress float (make sure that this float is between 0 and 1)


Here you go :slight_smile:

Cheers

IEnumerator Start ()
{
var op = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(sceneName);

	while (!op.isDone)
	{
		print(op.progress);
		yield return null;
	}
}