From 84f4d8007de2172561b40ecb94b4e1fe19a75271 Mon Sep 17 00:00:00 2001 From: neuecc Date: Thu, 7 May 2020 07:28:35 +0900 Subject: [PATCH] implicit operator UniTask -> UniTask --- src/UniTask/Assets/Plugins/UniTask/UniTask.cs | 5 +++++ src/UniTask/Assets/Scenes/SandboxMain.cs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/UniTask/Assets/Plugins/UniTask/UniTask.cs b/src/UniTask/Assets/Plugins/UniTask/UniTask.cs index 178c2f7..1958d3e 100644 --- a/src/UniTask/Assets/Plugins/UniTask/UniTask.cs +++ b/src/UniTask/Assets/Plugins/UniTask/UniTask.cs @@ -406,6 +406,11 @@ namespace Cysharp.Threading.Tasks return new UniTask(this.source, this.token); } + public static implicit operator UniTask(UniTask self) + { + return self.AsUniTask(); + } + /// /// returns (bool IsCanceled, T Result) instead of throws OperationCanceledException. /// diff --git a/src/UniTask/Assets/Scenes/SandboxMain.cs b/src/UniTask/Assets/Scenes/SandboxMain.cs index 43a79c9..43a76da 100644 --- a/src/UniTask/Assets/Scenes/SandboxMain.cs +++ b/src/UniTask/Assets/Scenes/SandboxMain.cs @@ -134,6 +134,9 @@ public class SandboxMain : MonoBehaviour Application.logMessageReceived += Application_logMessageReceived; + UniTask foo = UniTask.FromResult(10); + Foo(foo); + //ucs = new UniTaskCompletionSource(); //okButton.onClick.AddListener(async () => @@ -156,6 +159,10 @@ public class SandboxMain : MonoBehaviour }); } + static void Foo(UniTask t) + { + } + async UniTaskVoid Go(AsyncUpdateTrigger trigger, int i, CancellationToken ct) { await UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate);