Since 0.7.4 I´ve got a Problem with my loading screen. What I have been doing sofar was a simple Loadingscreen, with the function
public IEnumerator ShowProgress(AsyncOperationHandle op)
{
//this also seemingly doesn´t work anymore. What I currently do, just for testing is instead of GetDownloadSize(op) I replace the op with the actual object key, at least for now.
Addressables.GetDownloadSize(op).Completed += (AsyncOperationHandle<long> getValue) => { Downloadsize = getValue.Result; finishedGettingInfo = true; };
yield return new WaitUntil(() => finishedGettingInfo);
while (op.PercentComplete < 1)
{
progressBar.value = op.PercentComplete;
txtProgress.text = string.Format("{0:0.00}mb / {1:0.00}mb", (op.PercentComplete / 1000000) * 100, Downloadsize / 1000000);
yield return new WaitForSeconds(0.01f);
}
}
Pretty simple loading screen which worked for any Addressables Load I had. However, since 0.7.4, the op.PercentComplete doesn´t update at all. It only updates when the operation is basically done and op.PercentComplete = 1; It worked before IAsyncOperation got replaced with AsyncOperationHandle. Any advice whether I just have an error in the code now or if I need a new approach for this because maybe the AsyncOperationHandle doesn’t work exactle the same as it did before as IAsyncOperation.
And is it possible to get the object Key from AsyncOperationHandle?
Using Addressables 1.1.5, is there a way to cancel a AsyncOperationHandle?
I tried some of the following approaches, but no luck…
private AsyncOperationHandle asyncOperationObjectLoad;
public void LoadExperience()
{
this.onCompleteCreated = true;//flag for Update()
this.asyncOperationObjectLoad = this.experienceAsset.Instantiate();
this.asyncOperationObjectLoad.Completed += OnObjectLoaded;
}
public void DestroyLoadedAssets()
{
if (this.loadedExperience != null)
{
Addressables.Release(this.loadedExperience);
}
this.onCompleteCreated = false;
this.asyncOperationObjectLoad.Completed -= OnObjectLoaded;//doesn't work
StopAllCoroutines();//doesn't work
this.asyncOperationObjectLoad = new AsyncOperationHandle();//doesn't work
}
Also, still not able to get a value for AsyncOperationHandle.PercentComplete. Is there some sort of workaround?
For that matter, I’m doing the potential code in an Update loop, which is pretty janky to begin with. Is there a AsyncOperationHandle.onProgress or .onLoad to register to?
private void Update()
{
if (!this.isLoading)
return;
if (this.onCompleteCreated)
{
this.progressBar.SetValue(this.asyncOperationObjectLoad.PercentComplete);
}
else
{
this.progressBar.SetValue(0);
}
}
@unity_bill Or any other Unity staff. Any help would be much appreciated. Thank you!
We had fixed some case earlier, but tracked down what should be the main failing scenario recently. The fix is in our repo and will be in the next release.
not yet. We’ve looked into it. The problem is that some things you can do through addressable are cancel-able. Some not. So we haven’t added this yet as we can’t actually guarantee a reasonable behavior.
Hey Bill , Do you have a rough estimation when this next release will be? We’re trying to launch a production game asap and we need this PercentComplete bug fixed .
Either next week or the week after. Things are a little hard to nail down as a lot of the team is in and out on vacation over the summer. But I’m targeting fairly soon
Hey @Bobbiii GetDownloadSizeAsync doesn’t actually download anything, it just checks the location data for the download size. If Addressables is initialized this is basically a synchronous operation. The only reason you might see anything different than 1 on this operation is if Addressables hasn’t finished initialization and we chain the GetDownloadSizeAsync op with the init op.
@essamri what API are you using that you’re checking the progress of? I can take a look at how that specific operation works and make sure we haven’t missed something.
Do you have any updates on cancelling the AsyncOperationHandle? I’m creating a game with 3 HUGE stages and pre-loading them before the user selects a stage to play, my goal is to stop the other two and continue downloading the requested stage.