using System.Threading.Tasks; using UnityEngine; public static class AsyncOperationExtensions { /// /// Extension method that converts an AsyncOperation into a Task. /// /// The AsyncOperation to convert. /// A Task that represents the completion of the AsyncOperation. public static Task AsTask(this AsyncOperation asyncOperation) { var tcs = new TaskCompletionSource(); asyncOperation.completed += _ => tcs.SetResult(true); return tcs.Task; } }