UnityAsyncExtensions.MonoBehaviour.cs 422 B

1234567891011121314
  1. using System;
  2. using System.Threading;
  3. namespace Cysharp.Threading.Tasks
  4. {
  5. public static partial class UnityAsyncExtensions
  6. {
  7. public static UniTask StartAsyncCoroutine(this UnityEngine.MonoBehaviour monoBehaviour, Func<CancellationToken, UniTask> asyncCoroutine)
  8. {
  9. var token = monoBehaviour.GetCancellationTokenOnDestroy();
  10. return asyncCoroutine(token);
  11. }
  12. }
  13. }