Skip to content

Commit aa20f00

Browse files
authored
Merge pull request #138 from AnnulusGames/v2.0
LitMotion v2.0
2 parents 99e865b + 38095ee commit aa20f00

File tree

327 files changed

+13805
-2839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+13805
-2839
lines changed

README.md

+73-22
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,31 @@ LitMotion is a high-performance tween library for Unity. LitMotion includes a ri
1414

1515
LitMotion is my second tween library I created after [Magic Tween](https://github.com/AnnulusGames/MagicTween). LitMotion was designed based on experience implementing Magic Tween to achieve rich functionality and extremely high performance. In all situations such as creating and updating tweens, it exhibits overwhelming performance that is 2 to 20 times faster than other tween libraries. Of course, there is no allocation at all when creating a tween.
1616

17+
![img](./docs/images/img-v2-available.png)
18+
19+
Additionally, v2 introduces Sequence for combining multiple motions and the LitMotion.Animation package, which allows you to create tween animations directly from the Inspector. With these additions, LitMotion is now as powerful, if not more, than DOTween Pro or PrimeTween in terms of features.
20+
1721
## Documentation
1822

1923
The full version of documentation can be found [here](https://annulusgames.github.io/LitMotion/).
2024

2125
## Features
2226

23-
- Animate anything in one line of code.
24-
- Achieves zero allocations due to its struct-based design.
25-
- Highly optimized using DOTS (Data-Oriented Technology Stack).
26-
- Works in both runtime and editor.
27-
- Provides a rich set of schedulers, allowing you to specify the PlayerLoop to execute.
28-
- Apply complex settings like easing and looping.
29-
- Wait for completion via callbacks/coroutines.
30-
- Zero allocation string animation with FixedString and TextMeshPro
31-
- Character animation for TextMeshPro text.
32-
- Motion Tracker Window for monitoring motions in progress.
33-
- Convert to Observables using UniRx.
34-
- Convert to Observables using R3.
35-
- Supports async/await via UniTask.
36-
- Extend types using `IMotionOptions` and `IMotionAdapter`.
27+
* Animate anything in one line of code.
28+
* Achieves zero allocations with the struct-based design
29+
* Extremely high-performance implementation optimized using DOTS (Data-Oriented Technology Stack)
30+
* Works in both runtime and editor
31+
* Supports complex settings like easing and looping
32+
* Waits for completion using callbacks/coroutines
33+
* Zero allocation text animationSupports TextMesh Pro / UI Toolkit
34+
* Special motions like Punch, Shake, etc.
35+
* Conversion to Observable using [UniRx](https://github.com/neuecc/UniRx) / [R3](https://github.com/Cysharp/R3)
36+
* async/await support using [UniTask](https://github.com/Cysharp/UniTask)
37+
* Type extension with `IMotionOptions` and `IMotionAdapter`
38+
* Integration with the Inspector via `SerializableMotionSettings<T, TOptions>`
39+
* Debugging API and LitMotion Debugger window
40+
* Combine animations using `LSequence`
41+
* Create complex animations directly from the Inspector with the [LitMotion.Animation](articles/en/litmotion-animation-overview.md) package
3742

3843
## Setup
3944

@@ -74,7 +79,7 @@ Here's a sample code. Refer to the documentation for more details.
7479
using System;
7580
using System.Threading;
7681
using UnityEngine;
77-
using UniRx; // UniRx
82+
using R3; // R3
7883
using Cysharp.Threading.Tasks; // UniTask
7984
using LitMotion;
8085
using LitMotion.Extensions;
@@ -157,12 +162,12 @@ public class Example : MonoBehaviour
157162
await handle.ToUniTask(cancellationToken); // Await with passing CancellationToken
158163
}
159164

160-
// Convert to IObservable<T> using UniRx
165+
// Convert to Observable<T> using R3
161166
void RxExample()
162167
{
163168
LMotion.Create(0f, 1f, 2f)
164-
.ToObservable() // Create motion as IObservable<T>
165-
.Where(x => x > 0.5f) // Utilize UniRx operators
169+
.ToObservable() // Create motion as Observable<T>
170+
.Where(x => x > 0.5f) // Utilize R3 operators
166171
.Select(x => x.ToString())
167172
.Subscribe(x =>
168173
{
@@ -173,13 +178,59 @@ public class Example : MonoBehaviour
173178
}
174179
```
175180

176-
## Motion Tracker
181+
## Sequence
182+
183+
The Sequence feature is provided for combining multiple motions.
184+
185+
```cs
186+
LSequence.Create()
187+
.Append(LMotion.Create(0f, 1f, 1f).BindToPositionX(transform))
188+
.Join(LMotion.Create(0f, 1f, 1f).BindToPositionY(transform))
189+
.Insert(0f, LMotion.Create(0f, 1f, 1f).BindToPositionZ(transform))
190+
.Run();
191+
```
192+
193+
For more details, refer to the [Sequence](https://annulusgames.github.io/LitMotion/ja/sequence.html) section in the documentation.
194+
195+
## LitMotion.Animation
196+
197+
LitMotion.Animation is an additional package that provides animation functionality built with LitMotion.
198+
199+
By introducing this package, you can use the LitMotion Animation component to construct animations in the Inspector.
200+
201+
![img](./docs/images/img-litmotion-animation.gif)
202+
203+
204+
### Requirements
205+
206+
* Unity 2021.3 or later
207+
* LitMotion 2.0.0 or later
208+
209+
### Installation
210+
211+
You can install LitMotion using the Package Manager.
212+
213+
1. Open Package Manager by navigating to Window > Package Manager.
214+
2. Click on the "+" button and select "Add package from git URL."
215+
3. Enter the following URL:
216+
217+
```text
218+
https://github.com/AnnulusGames/LitMotion.git?path=src/LitMotion/Assets/LitMotion.Animation
219+
```
220+
221+
Alternatively, you can open the `Packages/manifest.json` file and add the following line within the `dependencies` block:
177222

178-
You can track all active motions using the Motion Tracker Window.
223+
```json
224+
{
225+
"dependencies": {
226+
"com.annulusgames.lit-motion.animation": "https://github.com/AnnulusGames/LitMotion.git?path=src/LitMotion/Assets/LitMotion.Animation"
227+
}
228+
}
229+
```
179230

180-
<img src="https://annulusgames.github.io/LitMotion/images/motion-tracker-window.png" width="800">
231+
### How to Use
181232

182-
For more details, please refer to [Motion Tracker](https://annulusgames.github.io/LitMotion/articles/en/motion-tracker.html).
233+
For how to use LitMotion.Animation, please refer to the documentation on [LitMotion.Animation](https://annulusgames.github.io/LitMotion/ja/litmotion-animation-overview.html).
183234

184235
## Performance
185236

README_JA.md

+69-22
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,32 @@ LitMotionはUnity向けのハイパフォーマンスなトゥイーンライブ
1414

1515
LitMotionは[Magic Tween](https://github.com/AnnulusGames/MagicTween)に続いて私が作成した2つ目のトゥイーンライブラリです。LitMotionはMagic Tweenの実装で得た経験をもとに、必要十分な機能を厳選しつつ、最速で動作させることを念頭に置いて設計されました。トゥイーンの作成や駆動などあらゆるシチュエーションにおいて、他のトゥイーンライブラリと比較して2倍から20倍以上の圧倒的なパフォーマンスを発揮します。当然、トゥイーン作成時のアロケーションも一切ありません。
1616

17+
![img](./docs/images/img-v2-available.png)
18+
19+
また、v2より複数のモーションを合成するためのSequenceと、Inspectorからトゥイーンアニメーションを作成可能なLitMotion.Animationパッケージが追加されました。これにより機能面においてもDOTween ProやPrimeTweenと同等または以上に強力なライブラリとなっています。
20+
1721
## ドキュメント
1822

1923
ドキュメントのフルバージョンは[こちら](https://annulusgames.github.io/LitMotion/)から確認できます。
2024

2125
## 特徴
2226

23-
- あらゆる値をコード一行でアニメーション可能
24-
- 構造体ベースの設計でゼロアロケーションを達成
25-
- DOTSを活用して最適化された極めてハイパフォーマンスな実装
26-
- ランタイムとエディタの両方で動作
27-
- 実行するPlayerLoopを指定する豊富なSchedulerを用意
28-
- イージングや繰り返しなど複雑な設定を適用可能
29-
- コールバック/コルーチンによる完了の待機
30-
- FixedStringとTextMeshProによるゼロアロケーションな文字列のアニメーション
31-
- TextMeshProのテキストを文字ごとにアニメーション可能
32-
- MotionTrackerウィンドウによる動作中のモーションの追跡
33-
- UniRxを利用したObservableへの変換
34-
- R3を利用したObservableへの変換
35-
- UniTaskを利用したasync/await対応
36-
- `IMotionOptions``IMotionAdapter`を用いた型の拡張
27+
* あらゆる値をコード一行でアニメーション可能
28+
* 構造体ベースの設計でゼロアロケーションを達成
29+
* DOTSを活用して最適化された極めてハイパフォーマンスな実装
30+
* ランタイムとエディタの両方で動作
31+
* イージングや繰り返しなど複雑な設定を適用可能
32+
* コールバック/コルーチンによる完了の待機
33+
* ゼロアロケーションなテキストアニメーション
34+
* TextMesh Pro / UI Toolkitに対応
35+
* Punch、Shakeなどの特殊なモーション
36+
* UniRx/R3を利用したObservableへの変換
37+
* UniTaskを利用したasync/await対応
38+
* `IMotionOptions``IMotionAdapter`を用いた型の拡張
39+
* `SerializableMotionSettings<T, TOptions>`によるInspectorとの統合
40+
* デバッグ用のAPIおよびLitMotion Debuggerウィンドウ
41+
* Sequenceによるアニメーションの合成
42+
* Inspectorから複雑なアニメーションを作成可能なLitMotion.Animationパッケージ
3743

3844
## セットアップ
3945

@@ -74,7 +80,7 @@ LitMotionを用いることでTransformやMaterialなどの値を簡単にアニ
7480
using System;
7581
using System.Threading;
7682
using UnityEngine;
77-
using UniRx; // UniRx
83+
using R3; // R3
7884
using Cysharp.Threading.Tasks; // UniTask
7985
using LitMotion;
8086
using LitMotion.Extensions;
@@ -157,12 +163,12 @@ public class Example : MonoBehaviour
157163
await handle.ToUniTask(cancellationToken); // ToUniTaskでCancellationTokenを渡してawait
158164
}
159165

160-
// UniRxを利用したIObservable<T>への変換に対応
166+
// R3を利用したObservable<T>への変換に対応
161167
void RxExample()
162168
{
163169
LMotion.Create(0f, 1f, 2f)
164-
.ToObservable() // モーションをIObservable<T>として作成
165-
.Where(x => x > 0.5f) // UniRxのオペレータを利用可能
170+
.ToObservable() // モーションをObservable<T>として作成
171+
.Where(x => x > 0.5f) // R3のオペレータを利用可能
166172
.Select(x => x.ToString())
167173
.Subscribe(x =>
168174
{
@@ -173,13 +179,54 @@ public class Example : MonoBehaviour
173179
}
174180
```
175181

176-
## Motion Tracker
182+
## Sequence
183+
184+
複数のモーションを合成するための機能として、Sequenceが提供されています。
185+
186+
```cs
187+
LSequence.Create()
188+
.Append(LMotion.Create(0f, 1f, 1f).BindToPositionX(transform))
189+
.Join(LMotion.Create(0f, 1f, 1f).BindToPositionY(transform))
190+
.Insert(0f, LMotion.Create(0f, 1f, 1f).BindToPositionZ(transform))
191+
.Run();
192+
```
193+
194+
詳細はドキュメントの[Sequence](https://annulusgames.github.io/LitMotion/ja/sequence.html)を参照してください。
195+
196+
## LitMotion.Animation
197+
198+
LitMotion.AnimationはLitMotionで構築されたアニメーションの機能を提供する追加パッケージです。これを導入することで、Inspector上でアニメーションを構築できるLitMotion Animationコンポーネントが利用可能になります。
199+
200+
![img](./docs/images/img-litmotion-animation.gif)
201+
202+
### 要件
203+
204+
* Unity 2021.3 以上
205+
* LitMotion 2.0.0 以上
206+
207+
### インストール
208+
209+
1. Window > Package ManagerからPackage Managerを開く
210+
2. 「+」ボタン > Add package from git URL
211+
3. 以下のURLを入力
212+
213+
```text
214+
https://github.com/AnnulusGames/LitMotion.git?path=src/LitMotion/Assets/LitMotion.Animation
215+
```
216+
217+
あるいはPackages/manifest.jsonを開き、dependenciesブロックに以下を追記します。
177218

178-
Motion Trackerウィンドウを使用して動作中の全てのモーションを追跡できます。
219+
```json
220+
{
221+
"dependencies": {
222+
"com.annulusgames.lit-motion.animation": "https://github.com/AnnulusGames/LitMotion.git?path=src/LitMotion/Assets/LitMotion.Animation"
223+
}
224+
}
225+
```
179226

180-
<img src="https://annulusgames.github.io/LitMotion/images/motion-tracker-window.png" width="800">
227+
### 使い方
181228

182-
詳細は[Motion Tracker](https://annulusgames.github.io/LitMotion/articles/ja/motion-tracker.html)を参照してください。
229+
LitMotion.Animationの使い方はドキュメントの[LitMotion.Animation](https://annulusgames.github.io/LitMotion/ja/litmotion-animation-overview.html)を参照してください。
183230

184231
## パフォーマンス
185232

docs/articles/en/about.md

-59
This file was deleted.

docs/articles/en/avoiding-dynamic-memory-allocation.md docs/articles/en/avoid-dynamic-memory-allocation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Avoiding Dynamic Memory Allocation
1+
## Avoid Dynamic Memory Allocation
22

33
You can expand the capacity of the internal array that holds motions beforehand by calling `MotionDispatcher.EnsureStorageCapacity()`. By ensuring the maximum anticipated capacity, such as during the app's startup, you can mitigate runtime dynamic memory allocation.
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Await Motion in async/await
2+
3+
`MotionHandle` implements the `GetAwaiter()` method, allowing you to directly await it to wait for completion.
4+
5+
```cs
6+
await handle;
7+
```
8+
9+
If you want to pass a `CancellationToken`, you can use `ToValueTask()` / `ToAwaitable()` or UniTask.
10+
11+
## ValueTask
12+
13+
You can convert a motion to a `ValueTask` using `MotionHandle.ToValueTask()`. This allows you to use async/await to wait for the completion of the motion.
14+
15+
```cs
16+
async ValueTask ExampleAsync(CancellationToken cancellationToken)
17+
{
18+
await LMotion.Create(0f, 10f, 1f)
19+
.RunWithoutBinding()
20+
.ToValueTask(cancellationToken);
21+
}
22+
```
23+
24+
However, using `ValueTask` in Unity has some performance concerns. For the best performance, it is recommended to use UniTask. For integration with UniTask, refer to the [UniTask](integration-unitask.md) guide.
25+
26+
### Awaitable
27+
28+
Starting from Unity 2023.1, Unity provides the [Awaitable](https://docs.unity3d.com/2023.1/Documentation/ScriptReference/Awaitable.html) class to enable efficient async/await handling within Unity.
29+
30+
If you're using Unity 2023.1 or later, LitMotion provides the `ToAwaitable()` extension method to convert a `MotionHandle` to an `Awaitable`. This allows you to use async/await to wait for motion completion.
31+
32+
```cs
33+
async Awaitable ExampleAsync(CancellationToken cancellationToken)
34+
{
35+
await LMotion.Create(0f, 10f, 1f)
36+
.RunWithoutBinding()
37+
.ToAwaitable(cancellationToken);
38+
}
39+
```
40+
41+
### Changing Behavior on Cancellation
42+
43+
By specifying `CancelBehavior` in the arguments for `ToValueTask()` / `ToAwaitable()`, you can change the behavior when the async method is canceled. Additionally, setting `cancelAwaitOnMotionCanceled` to `true` allows the async method to be canceled when the `MotionHandle` is canceled.
44+
45+
```cs
46+
await LMotion.Create(0f, 10f, 1f)
47+
.RunWithoutBinding()
48+
.ToAwaitable(CancelBehavior.Complete, true, cancellationToken);
49+
```

0 commit comments

Comments
 (0)