? BetterAnimation
BetterAnimation is a plug-in for converting Unity's AnimationClip into DOTween code, solving many of the shortcomings of Animation and Animator. It helps developers create and manage UI animations more easily in Unity.
? Advantages
Compared with traditional Unity Animation and Animator, BetterAnimation offers the following advantages:
- Avoid the problem of frame loss due to frame rate fluctuations under high fluctuations.
- Provides high degree of freedom control over easing function variables.
- Allows the Keyframe to be modified at runtime to achieve higher degree of freedom animation effects.
- More efficient, avoiding unnecessary computational overhead in many 2D projects.
- Supports inserting events into a single animation to avoid problems caused by universal animation.
- You can insert some code into the animation, such as pausing the animation and waiting for user input.
- Supports inverted animation playback while avoiding incorrect event callbacks.
- Supports chain programming.
- Quickly switch states and retain GameObject's current position, providing higher degrees of freedom.
- Supports multiple animations to play simultaneously.
- Provides a more powerful event triggering mechanism to support the acquisition of context data.
- Support coroutines, async and await, and more friendly support for asynchronous programming.
- More code-friendly and easy to view related data.
- Controllable life cycle and execution cycle
Roadmap
- Supports DOTS code and is suitable for high-performance and high-optimization environments.
- Support Generic animations
- Support Transition
- Abstract Tween functions.
- Refactoring and organizing code
- Provide more available low-level APIs
- Supplement more complex unit test cases
- Supplementary Benchmark Test
- Add support for Object sequence frames
How to use
- Add the
BetterAnimation script to the game object you wish to use. - Open
ProjectStteing to find Better Animation Config to modify the AOT code path and animation serialization file path - In the Unity Editor, add the required AnimationClip to the AnimationClip list in the
BetterAnimation component. - Call the
DoJob(animationName) method in the script, which will return an AnimationBuilder object for configuring and playing animations.
? Example
Here is a basic example of BetterAnimation:
public class BetterAnimationExample : MonoBehaviour
{
public BetterAnimation betterAnimation ;
private void Start ( )
{
var animationBuilder = betterAnimation . DoJob ( "ExampleAnimation" ) ;
animationBuilder . OnComplete ( ( ) => Debug . Log ( "Animation completed" ) )
. SetLoops ( 2 )
. Play ( ) ;
}
} ️ Notice
This plugin hooks Unity's Animation Window . You can also choose not to use hooks, but this may cause you to lose the following features:
- Unable to edit frame events directly : Using the hook function allows you to edit frame events directly, otherwise this will not be possible.
- Component compatibility : When using BetterAnimation components, the Animation/Animator component is still required, otherwise the Animation Window cannot detect the Animation Clip.
- Manually Operate Animation Clip : After creating an Animation Clip, you need to manually drag it into the BetterAnimation component.
❓ FAQ
Why is BetterAnimation faster than Animator?
Animator will modify their elements in each frame, even if the values in the animation are not changed. Animator has no checks without operation. For details, please refer to the official answer.