DOTween Documentation
repository·develop·Indexed 25 days ago
https://github.com/demigiant/dotweenA high-performance C# animation and tween engine for Unity developed by Daniele Giardini. It features a fluent API for animating properties, creating complex sequences, and implementing physical-style animations like Punch and Shake. The engine includes global configuration settings, capacity management to prevent performance hiccups, and virtual tweens via DOVirtual for non-object-based logic.
What's inside DOTween
- DOTween is a C# animation and tweening engine designed specifically for Unity. It provides a high-performance way to animate properties, create shortcuts, and use lambda expressions for complex tweening logic.
Access DOTween Utility Panel and Preferences
developThe DOTween Utility Panel is the central hub for managing the library. It can be accessed via
Tools > DOTween Utility Panel. The panel contains:- Setup tools for Unity version compatibility.
- Various useful utility options.
- A dedicated tab to manage DOTween's preferences.
Upgrade DOTween to version 1.2.815 or newer
developTo upgrade from versions older than 1.2.815 (or DOTween Pro older than 1.0.405), follow these steps exactly to avoid project errors:
- Import the new version: Import the update into the same folder as your existing installation (
Plugins/Demigiant), overwriting the old files. You may see errors during this process; ignore them for now. - Restart Unity: Close and reopen Unity and your project. Do not enter Safe Mode; this step is required to resolve the initial errors.
- Run Setup: Open the DOTween Utility Panel via
Tools > Demigiant > DOTween Utility Paneland click the "Setup DOTween..." button to run the upgrade setup. - Configure Modules: In the Add/Remove Modules panel that appears, activate or deactivate the modules required for Unity systems or external assets (Pro version only).
- Import the new version: Import the update into the same folder as your existing installation (
Set up DOTween in Unity
developAfter importing a new DOTween update, you must run the setup process to enable features specific to your Unity version.
- Navigate to the Tools menu in the Unity editor.
- Select DOTween Utility Panel (if it does not open automatically upon import).
- Click the Setup DOTween... button.
Get started with DOTween
developAfter importing DOTween, follow these steps to begin using it in your project:
- Initialize Setup: Open the DOTween Utility Panel from
Tools > Demigiant > DOTween Utility Paneland click "Setup DOTween..." to activate/deactivate necessary Modules. You can also use the Preferences tab in this panel to set default settings. - Add Namespace: In your C# scripts, add the following using directive to any class where you intend to use DOTween APIs:
using DG.Tweening;- Initialize Setup: Open the DOTween Utility Panel from
Use DOTween in C# scripts
developTo use DOTween APIs in your C# classes, include the following namespace directive at the top of your script:
using DG.Tweening;Upgrade DOTween from versions older than 1.2.000
developIf you are upgrading from a version older than 1.2.000 (or DOTween Pro older than 1.0.000), follow these steps to avoid errors:
- Import the new version into the same folder as the previous version, overwriting the old files. (Note: Errors may appear during this process).
- Close and reopen Unity and your project. This step is required to prevent significant issues.
- Open the DOTween Utility Panel via
Tools > Demigiant > DOTween Utility Panel(if it doesn't open automatically). - Click the "Setup DOTween..." button to run the upgrade setup.
- In the Add/Remove Modules panel, activate or deactivate the necessary Modules for Unity systems or external assets (Pro version only).
Set up DOTween in your project
developAfter importing DOTween, you must initialize it to activate the required modules and set preferences:
- Navigate to
Tools > Demigiant > DOTween Utility Panel. - Click the "Setup DOTween..." button.
- Use the Add/Remove Modules panel to enable/disable specific Unity system modules.
- Use the Preferences Tab within the Utility Panel to configure your default DOTween settings.
- Navigate to
Setup DOTween in Unity
developAfter importing a new DOTween update, you must run the setup process to enable features specific to your Unity version:
- Open the DOTween Utility Panel from the Unity menu:
Tools > DOTween Utility Panel. - Click the "Setup DOTween..." button within the panel.
If the panel does not open automatically upon import, use the menu path mentioned above.
- Open the DOTween Utility Panel from the Unity menu:
Access the DOTween Utility Panel
developThe DOTween Utility Panel is the central hub for managing the library. You can access it via the Unity menu:
Tools > Demigiant > DOTween Utility PanelIt provides the following functionality:
- Setup DOTween...: Runs the module activation/deactivation setup.
- Add/Remove Modules: Allows you to enable/disable support for specific Unity systems or external assets (Pro version).
- Preferences Tab: Allows you to configure default settings for DOTween.
Initialize DOTween
developCall
DOTween.Initonce before your first tween call to configure global settings. If not called, DOTween will initialize automatically with default options. You can chainSetCapacityto define the initial maximum number of Tweeners and Sequences to avoid performance hiccups caused by automatic capacity increases.Note on Recycling: If
recycleAllByDefaultis set totrue, killed tweens are reused from a pool instead of being destroyed. This reduces GC allocations but requires careful management of tween references. To avoid stale references, use theOnKillcallback to nullify your references:.OnKill(() => myTweenReference = null)DOTween.Init(false, false, LogBehaviour.Default).SetCapacity(100, 20);Wait for Tweens in Coroutines
developUse the following
WaitFor...extension methods as yield instructions inside Unity Coroutines to wait for specific tween states:yield return myTween.WaitForCompletion();: Waits until killed or complete.yield return myTween.WaitForRewind();: Waits until killed or rewinded.yield return myTween.WaitForKill();: Waits until killed.yield return myTween.WaitForElapsedLoops(int count);: Waits for a specific number of loops.yield return myTween.WaitForPosition(float position);: Waits until a specific position is reached.yield return myTween.WaitForStart();: Waits until the tween starts playing.
IEnumerator MyCoroutine(Tween myTween) { yield return myTween.WaitForStart(); yield return myTween.WaitForElapsedLoops(2); yield return myTween.WaitForCompletion(); }