First stable release of UniTask v2.
It has many improvement and some breaking changes from v1.
New Features
- Almost all UniTask methods and
async
method automatically reuse(zero allocation) and reduced heap allocation size - Asynchronous LINQ,
UniTaskAsyncEnumerable
standard factory and all linq operators and Unity specified factory generator - uGUI component has
***AsAsyncEnumerable
that converts event to async stream. - All async triggers(
Cysharp.Threading.Tasks.Triggers
) implementsIUniTaskAsyncEnumerable<T>
- Stacktrace in PlayerLoop shows current PlayerLoopTiming
- Available .NET Core package in NuGet
- Improved UniTaskTracker Window, enable a jump to the source file and TaskName displays generics type name
DOTween
support in default(require tocom.demigiant.dotween
import from OpenUPM or defineUNITASK_DOTWEEN_SUPPORT
)Addressable
support in default(AsyncOperationHandle
andAsyncOpereationHandle<T>
as awaitable)UniTaskCompletionSource
can reuse by.Reset()
- New last PlayerLoopTimings (
PlayerLoopTiming.LastPostLateUpdate
is same asWaitForEndOfFrame
) - New
AsyncReactiveProperty
,AsyncReadOnlyReactiveProperty
, that similar asReactiveProperty
in UniRx - New
Channel.CreateSingleConsumerUnbounded
, that is equivalent toSystem.Threading.Channels
, similar as go channel - TaskPool to set/monitor pooling size by
TaskPool.SetMaxPoolSize
,TaskPool.GetCacheSizeInfo
New Methods
- Add
UniTask.Preserve
, it converts to allow multiple await - Add
UniTask.WaitUntilCanceled
- Add
UniTask.Create
- Add
UniTask.Defer
- Add
UniTask.Action/UnityAction
- Add
JobHandle.WaitAsync
- Add
CancellationToken.WaitUntilCanceled
extension method - Add
UnityEvent<T>
andInputField
AsyncEventHandler and extensions - Add
WithCancellation
method to all async operation extensions
Changed from UniTask v1
- Namespace change:
UniRx.Async
->Cysharp.Threading.Tasks
- All
UniTask
/UniTask<T>
can not await twice(will throw exception), Reusable Promise is discontinuance - All UniTask Factory method(such as
UniTask.Delay
) run immediately(same as standard Task, previously it does not run before call await) - All Trigger method combinates
GetAsync***Trigger
andGet***AsyncHandler
and***Async
. UniTask.Lazy
returnsAsyncLazy<T>
- UniTask accepts
IUniTaskSource
instead ofIAwaiter
UniTask.WhenAny
return type is changed to(int winArgumentIndex, T1 result1, T2 result2, ...)
UniTask.WhenAll
's tuple does not use specified nameUniTaskScheduler.UnobservedExceptionWriteLogType
's default is changed toLogType.Exception
UniTaskVoid
can not awaitIObservable<T>.ToUniTask
parameter order changed fromCancellationToken cancellationToken, bool useFirst
tobool useFirst, CancellationToken cancellationToken
UniTask.VoidAction
is renamed toUniTask.Action
UniTask.DelayFrame
return type is changed fromUniTask<int>
toUniTask
UniTask.Void/Action/UnityAction
type is changed fromFunc<UniTask>
toFunc<UniTaskVoid>
- Removed
ConfigureAwait
method from all async operation extensions(renamed toToUniTask
) - Removed
new UniTask(factory)
, useUniTask.Create
orUniTask.Lazy
instead - UnityWebRequest's AsyncOperation calls
UnityWebRequest.Abort()
when detect canceled - JobHandle await extension does not accept
CancellationToken
- Lower Unity support version is changed to
2018.4.13f1
- Modified directory structure, under
Runtime
andEdtior
directory to follow standard UPM design