From 5c668717d8b5873c5a73efd755d0f6a4d4de6ae0 Mon Sep 17 00:00:00 2001 From: neuecc Date: Thu, 3 Mar 2022 06:23:34 +0900 Subject: [PATCH] Run DelayFrame on UnityEditor --- src/UniTask/Assets/Editor/EditorRunnerChecker.cs | 4 +++- .../Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/UniTask/Assets/Editor/EditorRunnerChecker.cs b/src/UniTask/Assets/Editor/EditorRunnerChecker.cs index b91524d..d4afbc8 100644 --- a/src/UniTask/Assets/Editor/EditorRunnerChecker.cs +++ b/src/UniTask/Assets/Editor/EditorRunnerChecker.cs @@ -22,7 +22,9 @@ public static class EditorRunnerChecker //var r = await UnityWebRequest.Get("https://bing.com/").SendWebRequest().ToUniTask(); //Debug.Log(r.downloadHandler.text.Substring(0, 100)); - await UniTask.Yield(); + //await UniTask.Yield(); + + await UniTask.DelayFrame(30); Debug.Log("End"); } diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs index fc32d51..5c56747 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs @@ -444,7 +444,19 @@ namespace Cysharp.Threading.Tasks // skip in initial frame. if (initialFrame == Time.frameCount) { +#if UNITY_EDITOR + // force use Realtime. + if (PlayerLoopHelper.IsMainThread && !UnityEditor.EditorApplication.isPlaying) + { + //goto ++currentFrameCount + } + else + { + return true; + } +#else return true; +#endif } }