using Cysharp.Threading.Tasks; using UnityGameFramework.Runtime; using ResourceApplySuccessEventArgs = UnityGameFramework.Runtime.ResourceApplySuccessEventArgs; using ResourceUpdateAllCompleteEventArgs = UnityGameFramework.Runtime.ResourceUpdateAllCompleteEventArgs; using ResourceVerifySuccessEventArgs = UnityGameFramework.Runtime.ResourceVerifySuccessEventArgs; namespace SepCore.AsyncTask { /// /// Resource 异步扩展方法 /// public static class ResourceAsyncExtension { /// /// 异步等待资源更新完成 /// /// 资源组件 /// 超时时间(秒),0表示不超时 /// 更新完成事件 public static UniTask WaitForResourceUpdateCompleteAsync(this ResourceComponent resourceComponent, float timeout = 0f) { return AsyncTaskHelper.WaitEventAsync( ResourceUpdateAllCompleteEventArgs.EventId, null, timeout ); } /// /// 异步等待资源验证完成 /// /// 资源组件 /// 超时时间(秒),0表示不超时 /// 验证成功事件 public static UniTask WaitForResourceVerifyCompleteAsync(this ResourceComponent resourceComponent, float timeout = 0f) { return AsyncTaskHelper.WaitEventAsync( ResourceVerifySuccessEventArgs.EventId, null, timeout ); } /// /// 异步等待资源应用完成 /// /// 资源组件 /// 超时时间(秒),0表示不超时 /// 应用成功事件 public static UniTask WaitForResourceApplyCompleteAsync(this ResourceComponent resourceComponent, float timeout = 0f) { return AsyncTaskHelper.WaitEventAsync( ResourceApplySuccessEventArgs.EventId, null, timeout ); } } }