You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+73-22
Original file line number
Diff line number
Diff line change
@@ -14,26 +14,31 @@ LitMotion is a high-performance tween library for Unity. LitMotion includes a ri
14
14
15
15
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.
16
16
17
+

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
+
17
21
## Documentation
18
22
19
23
The full version of documentation can be found [here](https://annulusgames.github.io/LitMotion/).
20
24
21
25
## Features
22
26
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
37
42
38
43
## Setup
39
44
@@ -74,7 +79,7 @@ Here's a sample code. Refer to the documentation for more details.
74
79
usingSystem;
75
80
usingSystem.Threading;
76
81
usingUnityEngine;
77
-
usingUniRx; //UniRx
82
+
usingR3; //R3
78
83
usingCysharp.Threading.Tasks; // UniTask
79
84
usingLitMotion;
80
85
usingLitMotion.Extensions;
@@ -157,12 +162,12 @@ public class Example : MonoBehaviour
157
162
awaithandle.ToUniTask(cancellationToken); // Await with passing CancellationToken
158
163
}
159
164
160
-
// Convert to IObservable<T> using UniRx
165
+
// Convert to Observable<T> using R3
161
166
voidRxExample()
162
167
{
163
168
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
166
171
.Select(x=>x.ToString())
167
172
.Subscribe(x=>
168
173
{
@@ -173,13 +178,59 @@ public class Example : MonoBehaviour
173
178
}
174
179
```
175
180
176
-
## Motion Tracker
181
+
## Sequence
182
+
183
+
The Sequence feature is provided for combining multiple motions.
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).
Copy file name to clipboardexpand all lines: docs/articles/en/avoid-dynamic-memory-allocation.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
## Avoiding Dynamic Memory Allocation
1
+
## Avoid Dynamic Memory Allocation
2
2
3
3
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.
`MotionHandle` implements the `GetAwaiter()` method, allowing you to directly await it to wait for completion.
4
+
5
+
```cs
6
+
awaithandle;
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.
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.
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.
0 commit comments