-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from AnnulusGames/update-docs
Update: docs
- Loading branch information
Showing
6 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Waiting for Motion in async/await | ||
|
||
`MotionHandle.ToValueTask()` allows you to convert a motion to a `ValueTask`. This enables you to await the completion of the motion using async/await. | ||
|
||
```cs | ||
async ValueTask ExampleAsync(CancellationToken cancellationToken) | ||
{ | ||
await LMotion.Create(0f, 10f, 1f) | ||
.RunWithoutBinding() | ||
.ToValueTask(cancellationToken); | ||
} | ||
``` | ||
|
||
However, using `ValueTask` in Unity may have performance implications. For optimal performance, it is recommended to use UniTask. Refer to [UniTask](integration-unitask.md) for information on integrating UniTask with LitMotion. | ||
|
||
### Awaitable | ||
|
||
Unity 2023.1 and later versions provide the [Awaitable](https://docs.unity3d.com/2023.1/Documentation/ScriptReference/Awaitable.html) class, which allows for efficient async/await in Unity. | ||
|
||
If you're using Unity 2023.1 or a later version, LitMotion provides an extension method `ToAwaitable()` to convert a `MotionHandle` into an `Awaitable`. This allows you to await the motion using async/await. | ||
|
||
```cs | ||
async Awaitable ExampleAsync(CancellationToken cancellationToken) | ||
{ | ||
await LMotion.Create(0f, 10f, 1f) | ||
.RunWithoutBinding() | ||
.ToAwaitable(cancellationToken); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# async/awaitでモーションを待機する | ||
|
||
`MotionHandle.ToValueTask()`を使用してモーションを`ValueTask`に変換することができます。これを使用することで、async/awaitでモーションの完了を待機することが可能になります。 | ||
|
||
```cs | ||
async ValueTask ExampleAsync(CancellationToken cancellationToken) | ||
{ | ||
await LMotion.Create(0f, 10f, 1f) | ||
.RunWithoutBinding() | ||
.ToValueTask(cancellationToken); | ||
} | ||
``` | ||
|
||
ただし、Unityにおいて`ValueTask`の使用はパフォーマンス上の問題を抱えています。最良のパフォーマンスを得るためにはUniTaskの使用を推奨します。UniTaskとの統合については[UniTask](integration-unitask.md)を参照してください。 | ||
|
||
### Awaitable | ||
|
||
Unity 2023.1以降では、Unityで効率的なasync/awaitを実現するためのクラスである[Awaitable](https://docs.unity3d.com/2023.1/Documentation/ScriptReference/Awaitable.html)が提供されています。 | ||
|
||
Unity 2023.1以降のバージョンを使用している場合、LitMotionでは`MotionHandle`を`Awaitable`に変換する拡張メソッドとして`ToAwaitable()`が提供されます。これを使用することで、async/awaitを利用してモーションを待機することができます。 | ||
|
||
```cs | ||
async Awaitable ExampleAsync(CancellationToken cancellationToken) | ||
{ | ||
await LMotion.Create(0f, 10f, 1f) | ||
.RunWithoutBinding() | ||
.ToAwaitable(cancellationToken); | ||
} | ||
``` |