Context:
I’m working on a WebGL build that consists of a very minimal bootstrap scene that then loads a fairly large initial core game payload that’s contained in a single scene. I’d very much like to be able to monitor the progress of the load so I can present some simple but diverting content in the interim. Very basic stuff, right?
However, when I test this, PercentComplete jumps immediately from 0 to .5 and then continues to hang at .5 until the scene is completely loaded. I’m testing this with a remote server on a veeeeery slow connection and the payload is relatively large, caches are cleared etc, so I would expect to see the progress slowly increment like it would with SceneManager.LoadSceneAsync (etc).
I’m using Unity 2018.3.12.f1 / Addressables package version 1.5.0
Here’s my very simple bootstrap code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.UI;
public class BootstrapController : MonoBehaviour
{
public string NextSceneAddress;
public float percentDone = 0;
[SerializeField] private Text LoadingText;
AsyncOperationHandle handle;
// Use this for initialization
void Start()
{
StartCoroutine(Bootstrap());
}
IEnumerator Bootstrap()
{
yield return null;
handle = Addressables.LoadSceneAsync(NextSceneAddress);
int i = 0; //increment; otherwise useless sanity check that the while loop is looping...
yield return null;
while (!handle.IsDone)
{
percentDone = Mathf.Floor(handle.PercentComplete * 100.0f);
LoadingText.text = i++ + " Loading " + percentDone.ToString() + "% Done";
yield return null;
}
// else scene should load automatically, right?
}
private void Update()
{
}
}