I've never used Addressables, but here is some relevant documentation:
Addressables also supports asynchronous await through the AsyncOperationHandle.Task property:
public async Start() {
AsyncOperationHandle<Texture2D> handle = Addressables.LoadAssetAsync<Texture2D>("mytexture");
await handle.Task;
// The task is complete. Be sure to check the Status is successful before storing the Result.
}
So to me it seems like you could switch to using Addressables, then do this:
private async void LoadSomethingAsync()
{
AsyncOperationHandle<AudioClip> handle = Addressables.LoadAssetAsync<AudioClip>("path");
await handle.Task;
if (handle.Status == AsyncOperationStatus.Succeeded)
{
AudioClip clip = handle.Result;
// use clip here
}
else
{
// handle loading error
}
}
Note that according to the documentation, this particular solution is not available on WebGL. This may not matter to you:
The AsyncOperationHandle.Task property is not available on WebGL as multi-threaded operations are not supported on that platform.
AsyncOperationmethod,LoadSceneAsync. It uses the code in this github. It should "just work" withLoadAsync<T>.if something like the code above is possible or not.. even if, you anyway will have to make surethe result is used in the main thread in the end since most of Unity API can not be used on other threadsbut they have multiple downsides.. like what for example? ;)