From 7bb3bf8d0e6c4dcc8019b5bd0b55ed7da771c1f9 Mon Sep 17 00:00:00 2001 From: Kochoyume <78918084+kochounoyume@users.noreply.github.com> Date: Tue, 30 Jan 2024 11:49:53 +0900 Subject: [PATCH 1/5] Update UniTask.Create, Unitask.Action and UniTask.UnityAction --- .../UniTask/Runtime/UniTask.Factory.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs index 2f6a6a9..6bff0ef 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs @@ -81,6 +81,16 @@ namespace Cysharp.Threading.Tasks return factory(); } + public static UniTask Create(Func factory, CancellationToken cancellationToken) + { + return factory(cancellationToken); + } + + public static UniTask Create(Func factory, T state) + { + return factory(state); + } + public static UniTask Create(Func> factory) { return factory(); @@ -137,6 +147,14 @@ namespace Cysharp.Threading.Tasks return () => asyncAction(cancellationToken).Forget(); } + /// + /// helper of create add UniTaskVoid to delegate. + /// + public static Action Action(Func asyncAction, T state) + { + return () => asyncAction(state).Forget(); + } + #if UNITY_2018_3_OR_NEWER /// @@ -157,6 +175,15 @@ namespace Cysharp.Threading.Tasks return () => asyncAction(cancellationToken).Forget(); } + /// + /// Create async void(UniTaskVoid) UnityAction. + /// For exampe: onClick.AddListener(UniTask.UnityAction(FooAsync, this.GetCancellationTokenOnDestroy())) + /// + public static UnityEngine.Events.UnityAction UnityAction(Func asyncAction, T state) + { + return () => asyncAction(state).Forget(); + } + #endif /// From 1496cc990ab795e9c2e8e06d712e5e83a9209638 Mon Sep 17 00:00:00 2001 From: Kochoyume <78918084+kochounoyume@users.noreply.github.com> Date: Tue, 30 Jan 2024 11:51:20 +0900 Subject: [PATCH 2/5] Fix misspelling --- .../Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs index 6bff0ef..471bd5d 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs @@ -159,7 +159,7 @@ namespace Cysharp.Threading.Tasks /// /// Create async void(UniTaskVoid) UnityAction. - /// For exampe: onClick.AddListener(UniTask.UnityAction(async () => { /* */ } )) + /// For example: onClick.AddListener(UniTask.UnityAction(async () => { /* */ } )) /// public static UnityEngine.Events.UnityAction UnityAction(Func asyncAction) { @@ -168,7 +168,7 @@ namespace Cysharp.Threading.Tasks /// /// Create async void(UniTaskVoid) UnityAction. - /// For exampe: onClick.AddListener(UniTask.UnityAction(FooAsync, this.GetCancellationTokenOnDestroy())) + /// For example: onClick.AddListener(UniTask.UnityAction(FooAsync, this.GetCancellationTokenOnDestroy())) /// public static UnityEngine.Events.UnityAction UnityAction(Func asyncAction, CancellationToken cancellationToken) { @@ -177,7 +177,7 @@ namespace Cysharp.Threading.Tasks /// /// Create async void(UniTaskVoid) UnityAction. - /// For exampe: onClick.AddListener(UniTask.UnityAction(FooAsync, this.GetCancellationTokenOnDestroy())) + /// For example: onClick.AddListener(UniTask.UnityAction(FooAsync, this.GetCancellationTokenOnDestroy())) /// public static UnityEngine.Events.UnityAction UnityAction(Func asyncAction, T state) { From 1e4561da2242aebaa13926d3735e46293eabf27d Mon Sep 17 00:00:00 2001 From: Kochoyume <78918084+kochounoyume@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:03:34 +0900 Subject: [PATCH 3/5] Fix comment --- src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs index 471bd5d..6c2babf 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs @@ -177,7 +177,7 @@ namespace Cysharp.Threading.Tasks /// /// Create async void(UniTaskVoid) UnityAction. - /// For example: onClick.AddListener(UniTask.UnityAction(FooAsync, this.GetCancellationTokenOnDestroy())) + /// For example: onClick.AddListener(UniTask.UnityAction(FooAsync, argument)) /// public static UnityEngine.Events.UnityAction UnityAction(Func asyncAction, T state) { From ca60864021235943d8add8bac9c4cd4be2ceec60 Mon Sep 17 00:00:00 2001 From: Kochoyume <78918084+kochounoyume@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:04:44 +0900 Subject: [PATCH 4/5] Fix comment --- src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs index 6c2babf..5942044 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs @@ -177,7 +177,7 @@ namespace Cysharp.Threading.Tasks /// /// Create async void(UniTaskVoid) UnityAction. - /// For example: onClick.AddListener(UniTask.UnityAction(FooAsync, argument)) + /// For example: onClick.AddListener(UniTask.UnityAction(FooAsync, Argument)) /// public static UnityEngine.Events.UnityAction UnityAction(Func asyncAction, T state) { From 28867646b0c65bce6550535950a635f6be8e1c03 Mon Sep 17 00:00:00 2001 From: Kochoyume <78918084+kochounoyume@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:05:18 +0900 Subject: [PATCH 5/5] Fix T state as the first argument --- .../Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs index 5942044..bd66aba 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs @@ -86,7 +86,7 @@ namespace Cysharp.Threading.Tasks return factory(cancellationToken); } - public static UniTask Create(Func factory, T state) + public static UniTask Create(T state, Func factory) { return factory(state); } @@ -150,7 +150,7 @@ namespace Cysharp.Threading.Tasks /// /// helper of create add UniTaskVoid to delegate. /// - public static Action Action(Func asyncAction, T state) + public static Action Action(T state, Func asyncAction) { return () => asyncAction(state).Forget(); } @@ -179,7 +179,7 @@ namespace Cysharp.Threading.Tasks /// Create async void(UniTaskVoid) UnityAction. /// For example: onClick.AddListener(UniTask.UnityAction(FooAsync, Argument)) /// - public static UnityEngine.Events.UnityAction UnityAction(Func asyncAction, T state) + public static UnityEngine.Events.UnityAction UnityAction(T state, Func asyncAction) { return () => asyncAction(state).Forget(); }