From 2e353244031f6b9d4bd1c49327ee725e37ed00c8 Mon Sep 17 00:00:00 2001 From: neuecc Date: Thu, 30 Jul 2020 08:12:32 +0900 Subject: [PATCH] ready for 2.0.27 --- .../Assets/Plugins/UniTask/package.json | 2 +- src/UniTask/Assets/Scenes/SandboxMain.cs | 43 +++++++++++++++---- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/package.json b/src/UniTask/Assets/Plugins/UniTask/package.json index a5b9efa..751d07d 100644 --- a/src/UniTask/Assets/Plugins/UniTask/package.json +++ b/src/UniTask/Assets/Plugins/UniTask/package.json @@ -1,7 +1,7 @@ { "name": "com.cysharp.unitask", "displayName": "UniTask", - "version": "2.0.26", + "version": "2.0.27", "unity": "2018.4", "description": "Provides an efficient async/await integration to Unity.", "keywords": [ "async/await", "async", "Task", "UniTask" ], diff --git a/src/UniTask/Assets/Scenes/SandboxMain.cs b/src/UniTask/Assets/Scenes/SandboxMain.cs index d64bbf6..a8cc69d 100644 --- a/src/UniTask/Assets/Scenes/SandboxMain.cs +++ b/src/UniTask/Assets/Scenes/SandboxMain.cs @@ -192,7 +192,7 @@ public class SandboxMain : MonoBehaviour async UniTask RunStandardDelayAsync() { - + UnityEngine.Debug.Log("DEB"); @@ -223,9 +223,9 @@ public class SandboxMain : MonoBehaviour async UniTaskVoid Update2() { - - + + @@ -464,7 +464,7 @@ public class SandboxMain : MonoBehaviour private void Awake() { - PlayerLoopInfo.Inject(); + // PlayerLoopInfo.Inject(); PrepareCamera(); } @@ -482,12 +482,24 @@ public class SandboxMain : MonoBehaviour }); } + async void RunStandardTaskAsync() + { + Debug.Log("Wait 3 seconds"); + await Task.Delay(TimeSpan.FromSeconds(3)); + + Debug.Log("Current SyncContext:" + SynchronizationContext.Current.GetType().FullName); + } + async UniTaskVoid Start() { - var url = "http://google.com/404"; - var webRequestAsyncOperation = UnityWebRequest.Get(url).SendWebRequest(); - await webRequestAsyncOperation.ToUniTask(); + RunStandardTaskAsync(); + + UnityEngine.Debug.Log("UniTaskPlayerLoop ready? " + PlayerLoopHelper.IsInjectedUniTaskPlayerLoop()); + + //var url = "http://google.com/404"; + //var webRequestAsyncOperation = UnityWebRequest.Get(url).SendWebRequest(); + //await webRequestAsyncOperation.ToUniTask(); //PlayerLoopInfo.Inject(); @@ -694,7 +706,9 @@ public class SandboxMain : MonoBehaviour //StartCoroutine(Coroutine()); - //await UniTask.Delay(TimeSpan.FromSeconds(1)); + // PlayerLoopInfo.Inject(); + await UniTask.Delay(TimeSpan.FromSeconds(1)); + PlayerLoopInfo.DumpPlayerLoop("current", PlayerLoop.GetCurrentPlayerLoop()); // _ = ReturnToMainThreadTest(); @@ -1060,6 +1074,17 @@ public class SandboxMain : MonoBehaviour } } + +public class SyncContextInjecter +{ + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] + public static void Inject() + { + SynchronizationContext.SetSynchronizationContext(new UniTaskSynchronizationContext()); + } +} + + public class PlayerLoopInfo { // [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] @@ -1094,7 +1119,7 @@ public class PlayerLoopInfo public static Type CurrentLoopType { get; private set; } - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] + // [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] public static void Inject() { var system = PlayerLoop.GetCurrentPlayerLoop();