mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-15 11:30:09 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c0f199fe0 |
@@ -135,8 +135,8 @@ namespace Cysharp.Threading.Tasks
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
cancellationTokenRegistration.Dispose();
|
||||
core.Reset();
|
||||
cancellationTokenRegistration.Dispose();
|
||||
cancellationTokenRegistration = default;
|
||||
parent.triggerEvent.Remove(this);
|
||||
parent = null;
|
||||
@@ -453,8 +453,8 @@ namespace Cysharp.Threading.Tasks
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
cancellationTokenRegistration.Dispose();
|
||||
core.Reset();
|
||||
cancellationTokenRegistration.Dispose();
|
||||
cancellationTokenRegistration = default;
|
||||
parent.triggerEvent.Remove(this);
|
||||
parent = null;
|
||||
|
||||
@@ -353,8 +353,8 @@ namespace Cysharp.Threading.Tasks
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
cancellationRegistration.Dispose();
|
||||
core.Reset();
|
||||
cancellationRegistration.Dispose();
|
||||
|
||||
RestoreOriginalCallback();
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace Cysharp.Threading.Tasks
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
TryReturn();
|
||||
}
|
||||
@@ -289,7 +289,6 @@ namespace Cysharp.Threading.Tasks
|
||||
return false;
|
||||
}
|
||||
|
||||
cancellationTokenRegistration.Dispose();
|
||||
core.TrySetResult(null);
|
||||
return false;
|
||||
}
|
||||
@@ -297,9 +296,9 @@ namespace Cysharp.Threading.Tasks
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
cancellationTokenRegistration.Dispose();
|
||||
core.Reset();
|
||||
cancellationToken = default;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
cancelImmediately = default;
|
||||
return pool.TryPush(this);
|
||||
}
|
||||
@@ -367,7 +366,7 @@ namespace Cysharp.Threading.Tasks
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
TryReturn();
|
||||
}
|
||||
@@ -413,9 +412,9 @@ namespace Cysharp.Threading.Tasks
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
cancellationTokenRegistration.Dispose();
|
||||
core.Reset();
|
||||
cancellationToken = default;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
return pool.TryPush(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ namespace Cysharp.Threading.Tasks
|
||||
return new UniTask(AsyncOperationConfiguredSource.Create(asyncOperation, timing, progress, cancellationToken, cancelImmediately, out var token), token);
|
||||
}
|
||||
|
||||
#if !UNITY_2023_1_OR_NEWER
|
||||
public struct AsyncOperationAwaiter : ICriticalNotifyCompletion
|
||||
{
|
||||
AsyncOperation asyncOperation;
|
||||
@@ -82,7 +81,6 @@ namespace Cysharp.Threading.Tasks
|
||||
asyncOperation.completed += continuationAction;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
sealed class AsyncOperationConfiguredSource : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<AsyncOperationConfiguredSource>
|
||||
{
|
||||
@@ -101,7 +99,6 @@ namespace Cysharp.Threading.Tasks
|
||||
CancellationTokenRegistration cancellationTokenRegistration;
|
||||
bool cancelImmediately;
|
||||
bool completed;
|
||||
bool allowReturn;
|
||||
|
||||
UniTaskCompletionSourceCore<AsyncUnit> core;
|
||||
|
||||
@@ -129,8 +126,7 @@ namespace Cysharp.Threading.Tasks
|
||||
result.cancellationToken = cancellationToken;
|
||||
result.cancelImmediately = cancelImmediately;
|
||||
result.completed = false;
|
||||
result.allowReturn = false;
|
||||
|
||||
|
||||
asyncOperation.completed += result.continuationAction;
|
||||
|
||||
if (cancelImmediately && cancellationToken.CanBeCanceled)
|
||||
@@ -158,16 +154,9 @@ namespace Cysharp.Threading.Tasks
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
if (allowReturn)
|
||||
{
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
allowReturn = true;
|
||||
}
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -194,15 +183,9 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (allowReturn)
|
||||
// Already completed
|
||||
if (completed || asyncOperation == null)
|
||||
{
|
||||
TryReturn();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (completed)
|
||||
{
|
||||
allowReturn = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -219,8 +202,6 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
if (asyncOperation.isDone)
|
||||
{
|
||||
cancellationTokenRegistration.Dispose();
|
||||
allowReturn = true;
|
||||
core.TrySetResult(AsyncUnit.Default);
|
||||
return false;
|
||||
}
|
||||
@@ -231,31 +212,29 @@ namespace Cysharp.Threading.Tasks
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
cancellationTokenRegistration.Dispose();
|
||||
core.Reset();
|
||||
asyncOperation.completed -= continuationAction;
|
||||
asyncOperation = default;
|
||||
progress = default;
|
||||
cancellationToken = default;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
cancelImmediately = default;
|
||||
return pool.TryPush(this);
|
||||
}
|
||||
|
||||
void Continuation(AsyncOperation _)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
completed = true;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
core.TrySetCanceled(cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.Report(asyncOperation.progress);
|
||||
}
|
||||
|
||||
core.TrySetResult(AsyncUnit.Default);
|
||||
}
|
||||
}
|
||||
@@ -350,7 +329,6 @@ namespace Cysharp.Threading.Tasks
|
||||
CancellationTokenRegistration cancellationTokenRegistration;
|
||||
bool cancelImmediately;
|
||||
bool completed;
|
||||
bool allowReturn;
|
||||
|
||||
UniTaskCompletionSourceCore<UnityEngine.Object> core;
|
||||
|
||||
@@ -378,8 +356,7 @@ namespace Cysharp.Threading.Tasks
|
||||
result.cancellationToken = cancellationToken;
|
||||
result.cancelImmediately = cancelImmediately;
|
||||
result.completed = false;
|
||||
result.allowReturn = false;
|
||||
|
||||
|
||||
asyncOperation.completed += result.continuationAction;
|
||||
|
||||
if (cancelImmediately && cancellationToken.CanBeCanceled)
|
||||
@@ -407,16 +384,9 @@ namespace Cysharp.Threading.Tasks
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
if (allowReturn)
|
||||
{
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
allowReturn = true;
|
||||
}
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -447,15 +417,9 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (allowReturn)
|
||||
// Already completed
|
||||
if (completed || asyncOperation == null)
|
||||
{
|
||||
TryReturn();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (completed)
|
||||
{
|
||||
allowReturn = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -472,8 +436,6 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
if (asyncOperation.isDone)
|
||||
{
|
||||
cancellationTokenRegistration.Dispose();
|
||||
allowReturn = true;
|
||||
core.TrySetResult(asyncOperation.asset);
|
||||
return false;
|
||||
}
|
||||
@@ -484,31 +446,29 @@ namespace Cysharp.Threading.Tasks
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
cancellationTokenRegistration.Dispose();
|
||||
core.Reset();
|
||||
asyncOperation.completed -= continuationAction;
|
||||
asyncOperation = default;
|
||||
progress = default;
|
||||
cancellationToken = default;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
cancelImmediately = default;
|
||||
return pool.TryPush(this);
|
||||
}
|
||||
|
||||
void Continuation(AsyncOperation _)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
completed = true;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
core.TrySetCanceled(cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.Report(asyncOperation.progress);
|
||||
}
|
||||
|
||||
core.TrySetResult(asyncOperation.asset);
|
||||
}
|
||||
}
|
||||
@@ -604,7 +564,6 @@ namespace Cysharp.Threading.Tasks
|
||||
CancellationTokenRegistration cancellationTokenRegistration;
|
||||
bool cancelImmediately;
|
||||
bool completed;
|
||||
bool allowReturn;
|
||||
|
||||
UniTaskCompletionSourceCore<UnityEngine.Object> core;
|
||||
|
||||
@@ -632,8 +591,7 @@ namespace Cysharp.Threading.Tasks
|
||||
result.cancellationToken = cancellationToken;
|
||||
result.cancelImmediately = cancelImmediately;
|
||||
result.completed = false;
|
||||
result.allowReturn = false;
|
||||
|
||||
|
||||
asyncOperation.completed += result.continuationAction;
|
||||
|
||||
if (cancelImmediately && cancellationToken.CanBeCanceled)
|
||||
@@ -661,16 +619,9 @@ namespace Cysharp.Threading.Tasks
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
if (allowReturn)
|
||||
{
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
allowReturn = true;
|
||||
}
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -701,15 +652,9 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (allowReturn)
|
||||
// Already completed
|
||||
if (completed || asyncOperation == null)
|
||||
{
|
||||
TryReturn();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (completed)
|
||||
{
|
||||
allowReturn = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -726,8 +671,6 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
if (asyncOperation.isDone)
|
||||
{
|
||||
cancellationTokenRegistration.Dispose();
|
||||
allowReturn = true;
|
||||
core.TrySetResult(asyncOperation.asset);
|
||||
return false;
|
||||
}
|
||||
@@ -738,31 +681,29 @@ namespace Cysharp.Threading.Tasks
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
cancellationTokenRegistration.Dispose();
|
||||
core.Reset();
|
||||
asyncOperation.completed -= continuationAction;
|
||||
asyncOperation = default;
|
||||
progress = default;
|
||||
cancellationToken = default;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
cancelImmediately = default;
|
||||
return pool.TryPush(this);
|
||||
}
|
||||
|
||||
void Continuation(AsyncOperation _)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
completed = true;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
core.TrySetCanceled(cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.Report(asyncOperation.progress);
|
||||
}
|
||||
|
||||
core.TrySetResult(asyncOperation.asset);
|
||||
}
|
||||
}
|
||||
@@ -859,7 +800,6 @@ namespace Cysharp.Threading.Tasks
|
||||
CancellationTokenRegistration cancellationTokenRegistration;
|
||||
bool cancelImmediately;
|
||||
bool completed;
|
||||
bool allowReturn;
|
||||
|
||||
UniTaskCompletionSourceCore<AssetBundle> core;
|
||||
|
||||
@@ -887,8 +827,7 @@ namespace Cysharp.Threading.Tasks
|
||||
result.cancellationToken = cancellationToken;
|
||||
result.cancelImmediately = cancelImmediately;
|
||||
result.completed = false;
|
||||
result.allowReturn = false;
|
||||
|
||||
|
||||
asyncOperation.completed += result.continuationAction;
|
||||
|
||||
if (cancelImmediately && cancellationToken.CanBeCanceled)
|
||||
@@ -916,16 +855,9 @@ namespace Cysharp.Threading.Tasks
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
if (allowReturn)
|
||||
{
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
allowReturn = true;
|
||||
}
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -956,15 +888,9 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (allowReturn)
|
||||
// Already completed
|
||||
if (completed || asyncOperation == null)
|
||||
{
|
||||
TryReturn();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (completed)
|
||||
{
|
||||
allowReturn = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -981,8 +907,6 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
if (asyncOperation.isDone)
|
||||
{
|
||||
cancellationTokenRegistration.Dispose();
|
||||
allowReturn = true;
|
||||
core.TrySetResult(asyncOperation.assetBundle);
|
||||
return false;
|
||||
}
|
||||
@@ -992,32 +916,30 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
bool TryReturn()
|
||||
{
|
||||
cancellationTokenRegistration.Dispose();
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.Reset();
|
||||
asyncOperation.completed -= continuationAction;
|
||||
asyncOperation = default;
|
||||
progress = default;
|
||||
cancellationToken = default;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
cancelImmediately = default;
|
||||
return pool.TryPush(this);
|
||||
}
|
||||
|
||||
void Continuation(AsyncOperation _)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
completed = true;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
core.TrySetCanceled(cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.Report(asyncOperation.progress);
|
||||
}
|
||||
|
||||
core.TrySetResult(asyncOperation.assetBundle);
|
||||
}
|
||||
}
|
||||
@@ -1129,7 +1051,6 @@ namespace Cysharp.Threading.Tasks
|
||||
CancellationTokenRegistration cancellationTokenRegistration;
|
||||
bool cancelImmediately;
|
||||
bool completed;
|
||||
bool allowReturn;
|
||||
|
||||
UniTaskCompletionSourceCore<UnityWebRequest> core;
|
||||
|
||||
@@ -1157,8 +1078,7 @@ namespace Cysharp.Threading.Tasks
|
||||
result.cancellationToken = cancellationToken;
|
||||
result.cancelImmediately = cancelImmediately;
|
||||
result.completed = false;
|
||||
result.allowReturn = false;
|
||||
|
||||
|
||||
asyncOperation.completed += result.continuationAction;
|
||||
|
||||
if (cancelImmediately && cancellationToken.CanBeCanceled)
|
||||
@@ -1187,16 +1107,9 @@ namespace Cysharp.Threading.Tasks
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
if (allowReturn)
|
||||
{
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
allowReturn = true;
|
||||
}
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1227,20 +1140,15 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (allowReturn)
|
||||
// Already completed
|
||||
if (completed || asyncOperation == null)
|
||||
{
|
||||
TryReturn();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (completed)
|
||||
{
|
||||
allowReturn = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
asyncOperation.webRequest.Abort();
|
||||
core.TrySetCanceled(cancellationToken);
|
||||
return false;
|
||||
}
|
||||
@@ -1252,9 +1160,14 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
if (asyncOperation.isDone)
|
||||
{
|
||||
cancellationTokenRegistration.Dispose();
|
||||
allowReturn = true;
|
||||
core.TrySetResult(asyncOperation.webRequest);
|
||||
if (asyncOperation.webRequest.IsError())
|
||||
{
|
||||
core.TrySetException(new UnityWebRequestException(asyncOperation.webRequest));
|
||||
}
|
||||
else
|
||||
{
|
||||
core.TrySetResult(asyncOperation.webRequest);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1263,22 +1176,24 @@ namespace Cysharp.Threading.Tasks
|
||||
|
||||
bool TryReturn()
|
||||
{
|
||||
cancellationTokenRegistration.Dispose();
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.Reset();
|
||||
asyncOperation.completed -= continuationAction;
|
||||
asyncOperation = default;
|
||||
progress = default;
|
||||
cancellationToken = default;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
cancelImmediately = default;
|
||||
return pool.TryPush(this);
|
||||
}
|
||||
|
||||
void Continuation(AsyncOperation _)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
completed = true;
|
||||
cancellationTokenRegistration.Dispose();
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
core.TrySetCanceled(cancellationToken);
|
||||
@@ -1289,11 +1204,6 @@ namespace Cysharp.Threading.Tasks
|
||||
}
|
||||
else
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.Report(asyncOperation.progress);
|
||||
}
|
||||
|
||||
core.TrySetResult(asyncOperation.webRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "com.cysharp.unitask",
|
||||
"displayName": "UniTask",
|
||||
"author": { "name": "Cysharp, Inc.", "url": "https://cysharp.co.jp/en/" },
|
||||
"version": "2.5.9",
|
||||
"version": "2.5.10",
|
||||
"unity": "2018.4",
|
||||
"description": "Provides an efficient async/await integration to Unity.",
|
||||
"keywords": [ "async/await", "async", "Task", "UniTask" ],
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b055f3837a55b4a44abf9bf4bcb3594f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1 +0,0 @@
|
||||
MyTEST
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49ccc900467d35543bb602a3de4d786a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -21,6 +21,7 @@ using System.Linq.Expressions;
|
||||
using UnityEngine.Events;
|
||||
|
||||
|
||||
|
||||
// using DG.Tweening;
|
||||
|
||||
|
||||
@@ -179,7 +180,7 @@ public class SandboxMain : MonoBehaviour
|
||||
|
||||
|
||||
//UnityAction action;
|
||||
|
||||
|
||||
|
||||
return 10;
|
||||
}
|
||||
@@ -591,78 +592,69 @@ public class SandboxMain : MonoBehaviour
|
||||
|
||||
async UniTaskVoid Start()
|
||||
{
|
||||
var p = Progress.Create<float>(x =>
|
||||
await new WhenEachTest().Each();
|
||||
|
||||
|
||||
// UniTask.Delay(TimeSpan.FromSeconds(1)).TimeoutWithoutException
|
||||
|
||||
|
||||
var currentLoop = PlayerLoop.GetDefaultPlayerLoop();
|
||||
PlayerLoopHelper.Initialize(ref currentLoop, InjectPlayerLoopTimings.Minimum); // minimum is Update | FixedUpdate | LastPostLateUpdate
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TestAsync(cts.Token).Forget();
|
||||
|
||||
okButton.onClick.AddListener(UniTask.UnityAction(async () =>
|
||||
{
|
||||
Debug.Log(x);
|
||||
});
|
||||
var foo = await Resources.LoadAsync("test2").ToUniTask(progress: p) as TextAsset;
|
||||
Debug.Log(foo.text);
|
||||
//var foo2 = await Resources.LoadAsync("test2").ToUniTask() as TextAsset;
|
||||
//Debug.Log(foo2.text); // onemore?
|
||||
await UniTask.WaitForEndOfFrame(this);
|
||||
var texture = new Texture2D(Screen.width, Screen.height);
|
||||
texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
|
||||
texture.Apply();
|
||||
|
||||
var jpg = texture.EncodeToJPG();
|
||||
File.WriteAllBytes("testscreencapture.jpg", jpg);
|
||||
Debug.Log("ok?");
|
||||
|
||||
//var texture = ScreenCapture.CaptureScreenshotAsTexture();
|
||||
//if (texture == null)
|
||||
//{
|
||||
// Debug.Log("fail");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var jpg = texture.EncodeToJPG();
|
||||
// File.WriteAllBytes("testscreencapture.jpg", jpg);
|
||||
// Debug.Log("ok?");
|
||||
//}
|
||||
}));
|
||||
|
||||
//await new WhenEachTest().Each();
|
||||
cancelButton.onClick.AddListener(UniTask.UnityAction(async () =>
|
||||
{
|
||||
//clickCancelSource.Cancel();
|
||||
|
||||
//RunCheck(PlayerLoopTiming.Initialization).Forget();
|
||||
//RunCheck(PlayerLoopTiming.LastInitialization).Forget();
|
||||
//RunCheck(PlayerLoopTiming.EarlyUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.LastEarlyUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.FixedUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.LastFixedUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.PreUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.LastPreUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.Update).Forget();
|
||||
//RunCheck(PlayerLoopTiming.LastUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.PreLateUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.LastPreLateUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.PostLateUpdate).Forget();
|
||||
//RunCheck(PlayerLoopTiming.LastPostLateUpdate).Forget();
|
||||
|
||||
//// UniTask.Delay(TimeSpan.FromSeconds(1)).TimeoutWithoutException
|
||||
await UniTask.Yield();
|
||||
}));
|
||||
|
||||
|
||||
//var currentLoop = PlayerLoop.GetDefaultPlayerLoop();
|
||||
//PlayerLoopHelper.Initialize(ref currentLoop, InjectPlayerLoopTimings.Minimum); // minimum is Update | FixedUpdate | LastPostLateUpdate
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//// TestAsync(cts.Token).Forget();
|
||||
|
||||
//okButton.onClick.AddListener(UniTask.UnityAction(async () =>
|
||||
//{
|
||||
// await UniTask.WaitForEndOfFrame(this);
|
||||
// var texture = new Texture2D(Screen.width, Screen.height);
|
||||
// texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
|
||||
// texture.Apply();
|
||||
|
||||
// var jpg = texture.EncodeToJPG();
|
||||
// File.WriteAllBytes("testscreencapture.jpg", jpg);
|
||||
// Debug.Log("ok?");
|
||||
|
||||
// //var texture = ScreenCapture.CaptureScreenshotAsTexture();
|
||||
// //if (texture == null)
|
||||
// //{
|
||||
// // Debug.Log("fail");
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // var jpg = texture.EncodeToJPG();
|
||||
// // File.WriteAllBytes("testscreencapture.jpg", jpg);
|
||||
// // Debug.Log("ok?");
|
||||
// //}
|
||||
//}));
|
||||
|
||||
//cancelButton.onClick.AddListener(UniTask.UnityAction(async () =>
|
||||
//{
|
||||
// //clickCancelSource.Cancel();
|
||||
|
||||
// //RunCheck(PlayerLoopTiming.Initialization).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.LastInitialization).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.EarlyUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.LastEarlyUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.FixedUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.LastFixedUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.PreUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.LastPreUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.Update).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.LastUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.PreLateUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.LastPreLateUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.PostLateUpdate).Forget();
|
||||
// //RunCheck(PlayerLoopTiming.LastPostLateUpdate).Forget();
|
||||
|
||||
// await UniTask.Yield();
|
||||
//}));
|
||||
await UniTask.Yield();
|
||||
}
|
||||
|
||||
async UniTaskVoid RunCheck(PlayerLoopTiming timing)
|
||||
|
||||
Reference in New Issue
Block a user