下载器

ExtensionAsyncOperation.cs 507B

12345678910111213141516171819
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. using System.Threading.Tasks;
  5. using UnityEngine;
  6. namespace TModule.Runtime
  7. {
  8. public static class ExtensionAsyncOperation
  9. {
  10. public static TaskAwaiter GetAwaiter(this AsyncOperation asyncOp)
  11. {
  12. var tcs = new TaskCompletionSource<object>();
  13. asyncOp.completed += obj => { tcs.SetResult(null); };
  14. return ((Task)tcs.Task).GetAwaiter();
  15. }
  16. }
  17. }