AsyncOperationHandle<Sprite> handle = Addressables.LoadAssetAsync<Sprite>(path);
if(!handle.IsDone)
yield return handle;
if (handle.Status == AsyncOperationStatus.Succeeded) {
Sprite s = handle.Result ;
myImage.sprite = s ;
Addressables.Release(handle);
}
unity 2020.3.4 LTS and current stable version of Addressables is 1.16.19
In editor mode there is no problem but in Android buid, if I release the handle, Sprite is also disappear.
When I check Addressables tutorials, they are generally release the handled variable after assigning.
Why is editor and android have different results.
Could you point me to this?
Handles should be kept and only released after the lifetime of the Asset you have loaded.
This is likely not so much that it is different in the Editor. But with the playmode script being used. If you are set to using “Use Existing Build”. Then the actual AssetBundles that are built are loaded, like they would be in the Release/Android.
With this mode, anything that is loaded, will be unloaded when all reference counts (Release calls) have been sent.
You are likely seeing this not happen with the other playmodes because they do not use the AssetBundles directly. The Assets are loaded from the AssetDatabase in the Editor are not unloaded in the same way. In general, always release handles once you no longer need the Asset, and use “Use existing build” where you want exact behaviour, with “use Asset Database” for development and iteration times.