The Solution to AsyncOperation.progress

I’ve noticed many people list or post in Unity forums saying that AsyncOperation.progress is broken or cannot be used for a loading progress indicator because it only goes from 0 and to 1.

The reason it does this though is due to floating point round off error, in which the float percentage from 0 to 1 is continually rounded down to 0 as it progresses. So the solution to have an actual progress is to multiply the AsyncOperation.progress by 100f, and check against that value. It will be out of 100.

Sample code:

public void Update() 
{  
		if(asyncOperation != null && !doneLoadingScene) 
		{  
			Debug.Log("Scene Load Progress: " + asyncOperation.progress * 100f); 
			if(asyncOperation.isDone) 
			{  
				doneLoadingScene = true; 
				Debug.Log("SCENE DONE LOADING!"); 
			}  
		}  
}

Posting my JS solution in case anybody is interested:

if(loaderwww.isLoading){ //isLoading is a simple boolean that gets FALSE when WWW.progress==1
		loadedbytes = loader.GetComponent(StoreDownloader).download;
		number = loadedbytes.progress; //this number variable is between 0 and 1.
		textMesh.text = Mathf.Round(number*100)+"%"; //A 3DText that shows progress of a download on a store window in my case.
	}

Hope this helps.