Fix DelayType.Realtime does not work when use BuildPlayer in UnityEditor
parent
5ced0a1d4b
commit
71879266ac
|
@ -257,3 +257,5 @@ src/UniTask/Assembly-CSharp.Player.csproj
|
||||||
src/UniTask/Unity.EditorCoroutines.Editor.csproj
|
src/UniTask/Unity.EditorCoroutines.Editor.csproj
|
||||||
|
|
||||||
src/UniTask/.vsconfig
|
src/UniTask/.vsconfig
|
||||||
|
|
||||||
|
src/UniTask/Logs/ApiUpdaterCheck.txt
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace Cysharp.Threading.Tasks.Internal
|
||||||
|
|
||||||
public TimeSpan Elapsed => TimeSpan.FromTicks(this.ElapsedTicks);
|
public TimeSpan Elapsed => TimeSpan.FromTicks(this.ElapsedTicks);
|
||||||
|
|
||||||
|
public bool IsInvalid => startTimestamp == 0;
|
||||||
|
|
||||||
public long ElapsedTicks
|
public long ElapsedTicks
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -726,6 +726,12 @@ namespace Cysharp.Threading.Tasks
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stopwatch.IsInvalid)
|
||||||
|
{
|
||||||
|
core.TrySetResult(AsyncUnit.Default);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (stopwatch.ElapsedTicks >= delayTimeSpanTicks)
|
if (stopwatch.ElapsedTicks >= delayTimeSpanTicks)
|
||||||
{
|
{
|
||||||
core.TrySetResult(AsyncUnit.Default);
|
core.TrySetResult(AsyncUnit.Default);
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Test1
|
||||||
|
{
|
||||||
|
[MenuItem("Test/Test1")]
|
||||||
|
public static async UniTaskVoid TestFunc()
|
||||||
|
{
|
||||||
|
await DoSomeThing();
|
||||||
|
string[] scenes = new string[]
|
||||||
|
{
|
||||||
|
"Assets/Scenes/SandboxMain.unity",
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Debug.Log("Build Begin");
|
||||||
|
BuildPipeline.BuildPlayer(scenes, Application.dataPath + "../target", BuildTarget.StandaloneWindows, BuildOptions.CompressWithLz4);
|
||||||
|
Debug.Log("Build After");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async UniTask DoSomeThing()
|
||||||
|
{
|
||||||
|
Debug.Log("Dosomething");
|
||||||
|
await UniTask.Delay(1500, DelayType.Realtime);
|
||||||
|
Debug.Log("Dosomething 2");
|
||||||
|
await UniTask.Delay(1000, DelayType.Realtime);
|
||||||
|
Debug.Log("Dosomething 3");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 48003021292963e48b2493e915dca5ac
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -577,7 +577,8 @@ public class SandboxMain : MonoBehaviour
|
||||||
StartCoroutine(LastYieldCore());
|
StartCoroutine(LastYieldCore());
|
||||||
|
|
||||||
Debug.Log("BEFORE:" + Time.frameCount);
|
Debug.Log("BEFORE:" + Time.frameCount);
|
||||||
|
|
||||||
|
await UniTask.Yield();
|
||||||
// await UniTask.Yield(PlayerLoopTiming.LastTimeUpdate);
|
// await UniTask.Yield(PlayerLoopTiming.LastTimeUpdate);
|
||||||
|
|
||||||
Debug.Log("AFTER:" + Time.frameCount);
|
Debug.Log("AFTER:" + Time.frameCount);
|
||||||
|
|
Loading…
Reference in New Issue