mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-15 11:30:09 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f82c762263 | ||
|
|
021a1da1fa | ||
|
|
5a934d382f | ||
|
|
fed4ba76b5 | ||
|
|
d98ceadfe9 | ||
|
|
b5774baccf | ||
|
|
9c8d9b2633 | ||
|
|
940e81034e | ||
|
|
d35d7dad3e |
@@ -36,7 +36,8 @@ jobs:
|
||||
name: Build Linux(Mono)
|
||||
command: /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend Mono2x /BuildTarget StandaloneLinux64
|
||||
working_directory: .
|
||||
- run: ./bin/UnitTest/StandaloneLinux64_Mono2x/test
|
||||
# TODO:check unity version and packages...
|
||||
# - run: ./bin/UnitTest/StandaloneLinux64_Mono2x/test
|
||||
build-and-create-package:
|
||||
parameters:
|
||||
unity_version: {type: string}
|
||||
|
||||
@@ -195,7 +195,6 @@ namespace UniRx.AsyncTests
|
||||
|
||||
var currentThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||
|
||||
UnityEngine.Debug.Log("Before:" + currentThreadId);
|
||||
|
||||
|
||||
await UniTask.SwitchToThreadPool();
|
||||
@@ -209,7 +208,6 @@ namespace UniRx.AsyncTests
|
||||
|
||||
var switchedThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||
|
||||
UnityEngine.Debug.Log("After:" + switchedThreadId);
|
||||
|
||||
|
||||
currentThreadId.Should().NotBe(switchedThreadId);
|
||||
@@ -376,6 +374,27 @@ namespace UniRx.AsyncTests
|
||||
throw new Exception("MyException");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator NestedEnumerator() => UniTask.ToCoroutine(async () =>
|
||||
{
|
||||
var time = Time.realtimeSinceStartup;
|
||||
|
||||
await ParentCoroutineEnumerator();
|
||||
|
||||
var elapsed = Time.realtimeSinceStartup - time;
|
||||
((int)Math.Round(TimeSpan.FromSeconds(elapsed).TotalSeconds, MidpointRounding.ToEven)).Should().Be(3);
|
||||
});
|
||||
|
||||
IEnumerator ParentCoroutineEnumerator()
|
||||
{
|
||||
yield return ChildCoroutineEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator ChildCoroutineEnumerator()
|
||||
{
|
||||
yield return new WaitForSeconds(3);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -191,7 +191,8 @@ namespace UniRx.Async
|
||||
}
|
||||
else if (current is IEnumerator e3)
|
||||
{
|
||||
while (e3.MoveNext())
|
||||
var e4 = ConsumeEnumerator(e3);
|
||||
while (e4.MoveNext())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
@@ -231,14 +232,6 @@ namespace UniRx.Async
|
||||
};
|
||||
}
|
||||
|
||||
static IEnumerator UnwrapEnumerator(IEnumerator enumerator)
|
||||
{
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerator UnwrapWaitAsyncOperation(AsyncOperation asyncOperation)
|
||||
{
|
||||
while (!asyncOperation.isDone)
|
||||
|
||||
@@ -67,13 +67,33 @@ namespace UniRx.Async
|
||||
var yieldLoop = new PlayerLoopSystem
|
||||
{
|
||||
type = loopRunnerYieldType,
|
||||
#if UNITY_EDITOR
|
||||
updateDelegate = () =>
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
cq.Run();
|
||||
}
|
||||
}
|
||||
#else
|
||||
updateDelegate = cq.Run
|
||||
#endif
|
||||
};
|
||||
|
||||
var runnerLoop = new PlayerLoopSystem
|
||||
{
|
||||
type = loopRunnerType,
|
||||
#if UNITY_EDITOR
|
||||
updateDelegate = () =>
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
runner.Run();
|
||||
}
|
||||
}
|
||||
#else
|
||||
updateDelegate = runner.Run
|
||||
#endif
|
||||
};
|
||||
|
||||
var dest = new PlayerLoopSystem[loopSystem.subSystemList.Length + 2];
|
||||
|
||||
14
README.md
14
README.md
@@ -4,11 +4,11 @@
|
||||
|
||||
Provides an efficient async/await integration to Unity.
|
||||
|
||||
> UniTask was included in UniRx before v6 but now completely separated, it no dependent each other.
|
||||
> UniTask was included in UniRx before v7 but now completely separated, it no dependent each other.
|
||||
|
||||
Getting started
|
||||
---
|
||||
Install package is available in [UniTask/releases](https://github.com/Cysharp/UniTask/releases) page.
|
||||
Install package(`UniRx.Async.unitypackage`) is available in [UniTask/releases](https://github.com/Cysharp/UniTask/releases) page.
|
||||
|
||||
```csharp
|
||||
// extension awaiter/methods can be used by this namespace
|
||||
@@ -192,6 +192,14 @@ UniTask.DelayFrame
|
||||
UniTask.Delay(..., bool ignoreTimeScale = false, ...) parameter
|
||||
```
|
||||
|
||||
Cancellation
|
||||
---
|
||||
|
||||
async void vs async UniTask/UniTaskVoid
|
||||
---
|
||||
|
||||
Progress
|
||||
---
|
||||
|
||||
For Unit Testing
|
||||
---
|
||||
@@ -201,4 +209,4 @@ Reference
|
||||
|
||||
License
|
||||
---
|
||||
This library is under the MIT License.
|
||||
This library is under the MIT License.
|
||||
|
||||
Reference in New Issue
Block a user