Hello,
at the moment I’m using a converter to bind to an image. Inside the viewmodel I have a string containing the reference to the image inside an addressable group. At the moment the converter looks as followed:
public struct StringToImageConverter
{
private static AsyncOperationHandle<Sprite> imageOperationHandle;
public static StyleBackground Convert(string name)
{
imageOperationHandle = Addressables.LoadAssetAsync<Sprite>(name);
imageOperationHandle.WaitForCompletion();
if (imageOperationHandle.Status == AsyncOperationStatus.Succeeded)
return new StyleBackground(imageOperationHandle.Result);
Debug.LogWarning("Failed to load image with name: " + name);
return null;
}
}
On desktop this is working correctly. But when using this code on WebGL I get an error about “imageOperationHandle.WaitForCompletion();” not supported in WebGL. Is there a better way to implement a converter with async operations? Preferable without moving the loading of the Sprite into the viewmodel.
Thanks in advance
Regards Stefan