Skip to content

Commit

Permalink
Update: documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnulusGames committed Dec 27, 2023
1 parent 7710390 commit 017e156
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/articles/en/motion-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Specifies the Scheduler used for motion playback.
| MotionScheduler.Update | Updates at the Update timing. |
| MotionScheduler.LateUpdate | Updates at the LateUpdate timing. |
| MotionScheduler.FixedUpdate | Updates at the FixedUpdate timing. |
| MotionScheduler.Manual | Updates manually. For details, see [Updating Motion Manually](updating-motion-manually.md). |
| EditorMotionScheduler.Update (LitMotion.Editor) | Updates at the EditorApplication.update timing. This Scheduler is limited to the editor. |

#### WithRoundingMode (int)
Expand Down
2 changes: 2 additions & 0 deletions docs/articles/en/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
href: motion-configuration.md
- name: Waiting for Motion in Coroutine
href: waiting-for-motion-in-coroutine.md
- name: Updating Motion Manually
href: updating-motion-manually.md
- name: Reusing MotionBuilder
href: reusing-builder.md
- name: Avoiding Dynamic Memory Allocation
Expand Down
30 changes: 30 additions & 0 deletions docs/articles/en/updating-motion-manually.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Updating Motion Manually

You can configure the motion's update process to be manual by specifying `MotionScheduler.Manual` as the scheduler.

```cs
// Specify MotionScheduler.Manual as the scheduler
var handle = LMotion.Create(value, endValue, 2f)
.WithScheduler(MotionScheduler.Manual)
.BindToUnityLogger();
```

For motions with `MotionScheduler.Manual`, you need to manually update the motion using `ManualMotionDispatcher.Update()`.

```cs
while (handle.IsActive())
{
var deltaTime = 0.1f;
// Update using ManualMotionDispatcher.Update()
ManualMotionDispatcher.Update(deltaTime);
}
```

Also, when you have disabled Domain Reload, the motion's state might not initialize, leading to unexpected behavior. To avoid this, explicitly initialize it at startup using `ManualMotionDispatcher.Reset()`.

```cs
void Awake()
{
ManualMotionDispatcher.Reset();
}
```
1 change: 1 addition & 0 deletions docs/articles/ja/motion-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ LMotion.Create(0f, 10f, 2f)
| MotionScheduler.Update | Updateのタイミングで更新を行います。 |
| MotionScheduler.LateUpdate | LateUpdateのタイミングで更新を行います。 |
| MotionScheduler.FixedUpdate | FixedUpdateのタイミングで更新を行います。 |
| MotionScheduler.Manual | 更新を手動で行います。詳細は[モーションを手動で更新する](updating-motion-manually.md)を参照してください。 |
| EditorMotionScheduler.Update (LitMotion.Editor) | EditorApplication.updateのタイミングで更新を行います。このSchedulerはエディタ限定で使用できます。 |

#### WithRoundingMode (int)
Expand Down
2 changes: 2 additions & 0 deletions docs/articles/ja/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
href: motion-configuration.md
- name: コルーチンでモーションを待機する
href: waiting-for-motion-in-coroutine.md
- name: モーションを手動で更新する
href: updating-motion-manually.md
- name: MotionBuilderを再利用する
href: reusing-builder.md
- name: 動的なメモリ確保を回避する
Expand Down
30 changes: 30 additions & 0 deletions docs/articles/ja/updating-motion-manually.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# モーションを手動で更新する

Schedulerに`MotionScheduler.Manual`を指定することで、モーションの更新処理を手動で行うように設定することができます。

```cs
// SchedulerにMotionScheduler.Manualを指定
var handle = LMotion.Create(value, endValue, 2f)
.WithScheduler(MotionScheduler.Manual)
.BindToUnityLogger();
```

`MotionScheduler.Manual`を指定したモーションは`ManualMotionDispatcher.Update()`を用いて手動で更新処理を行う必要があります。

```cs
while (handle.IsActive())
{
var deltaTime = 0.1f;
// ManualMotionDispatcher.Update()で更新を行う
ManualMotionDispatcher.Update(deltaTime);
}
```

またDomain Reloadをオフにしている場合、モーションの状態が初期化されないため予期しない動作を起こすことがあります。これを避けるためには、起動時に`ManualMotionDispatcher.Reset()`で明示的に初期化を行う必要があります。

```cs
void Awake()
{
ManualMotionDispatcher.Reset();
}
```

0 comments on commit 017e156

Please sign in to comment.