Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Magic Tween - Extremely fast tween library implemented in ECS

Discussion in 'Assets and Asset Store' started by annulusgames, Sep 9, 2023.

  1. annulusgames

    annulusgames

    Joined:
    Sep 24, 2020
    Posts:
    7
    Magic Tween is an extremely fast tween library implemented in ECS.



    Features
    • High-performance tweening library implemented in ECS.
    • Add extension methods compatible with many components.
    • Tween anything with Tween.To.
    • Apply various settings using method chaining.
    • Create complex animations with Sequences.
    • Add processing via callbacks.
    • Support for tweening TextMesh Pro.
    • Support for conversion to Observable with UniRx.
    • Support for async/await with UniTask.
    • Even higher-performance implementation for ECS.
    Performance



    When tweening float values of regular classes using Tween.To(), Magic Tween operates more than 2 to 5 times faster than other libraries.
    When tweening float values within ECS components using Tween.Entity.To(), it is possible to achieve even higher performance.

    This library is free and opensource on GitHub. Have fun!
    https://github.com/AnnulusGames/MagicTween
     
    saskenergy, thelebaron, Enzi and 5 others like this.
  2. annulusgames

    annulusgames

    Joined:
    Sep 24, 2020
    Posts:
    7
    Released v0.1.1. The change log is below.
    - Renewed tween components
    - Improved performance
    - Fixed minor bugs

    Although there are no new features, the internal structure has been redesigned to further improve performance. Specifically, the creation speed of Tween.Entity.To has been improved by about 40%, and the performance of Sequence has also been slightly improved.
    I would like to further improve performance and enhance functionality. I would be happy if you could let me know if you have any opinions or problems.
     
    saskenergy and alsomitra like this.
  3. digiwombat

    digiwombat

    Joined:
    Sep 26, 2013
    Posts:
    44
    Love to see another FOSS tweening solution. I'm noticing a lot of syntax similarity, but is this a drop-in replacement for DOTween? If no, which pieces need changing, if you know off the top of your head?
     
  4. annulusgames

    annulusgames

    Joined:
    Sep 24, 2020
    Posts:
    7
    Although not completely replaceable, it can be used as an alternative to DOTween in most situations. I used to use DOTween Pro for my projects, but now I have replaced all the relevant parts with Magic Tween and it is working without any problems.

    However, there are some features that are incompatible or unsupported compared to DOTween.

    - The behavior of OnPlay and OnStart is quite different from DOTween.
    - There is no extension method equivalent to DOJump.
    - You cannot rewind tween or change the playback direction.
    - There is no From method. However, you can specify the starting value when creating the tween, and SetInvert() is also available.
    - SetUpdate does not exist, and it is impossible to change the update timing.
    - In order to use async/await, UniTask must be installed. (If you want to use async/await in Unity, using the regular Task class is not good for performance.)
    - Magic Tween's TweenParams, SetAs(), and extension methods for coroutines (WaitForComplete, WaitForKill, etc...) are currently experimental and will not work correctly. These will be supported in future updates.
    - There is no visual editor. (currently under development)
     
  5. digiwombat

    digiwombat

    Joined:
    Sep 26, 2013
    Posts:
    44
    Thanks, that's basically all the stuff I wanted to know. It'll definitely help speed up switching on our current project. :D
     
  6. calabi

    calabi

    Joined:
    Oct 29, 2009
    Posts:
    232
    This is awesome, thanks. I've been waiting for something like this and I new it would be performant.
     
  7. annulusgames

    annulusgames

    Joined:
    Sep 24, 2020
    Posts:
    7
    Magic Tween v0.2 has been released!

    This release includes several new features and significant performance improvements. The changes are as follows.

    - Zero GC allocation
    From v0.2, GC allocation when creating Tween has been completely reduced. This will reduce the frequency of GC collects, which is expected to improve performance. (However, some tweens, such as string tweens, still cause allocation.)
    Also added method overloads to avoid lambda expression allocation when adding callbacks.

    - Burst compatible
    The methods below Tween.Entity now support Burst. This improves performance when creating tweens for ECS.

    - Added tweens optimized for Transform
    benchmark_transform_tween_job.png


    By incorporating IJobParallelForTransform internally, I was able to dramatically improve the performance of the Transform tween. This feature is enabled by adding
    MAGICTWEEN_ENABLE_TRANSFORM_JOBS
    to Project Settings > Scripting Define Symbols.

    - Added ICustomTweenPlugin
    You can now create extensions that tween your own types by defining a struct that implements
    ICustomTweenPlugin
    . By utilizing SourceGenerator, easy and high-performance expansion is achieved.
    The actual implementation method is described in the README, and you can also see an implementation example of TweenPlugin that supports
    UnityEngine.Rect
    in the MagicTween.Samples project.

    - Supports coroutines
    Added a method to wait for Tween inside a coroutine. You can wait until any timing by using the methods starting with WaitFor....

    This version also includes some breaking changes regarding the API around ECS. Please refer to migration.md for migration to v0.2.
     
    saskenergy likes this.