What is Unity DOTween? How to Use It?

Unity DOTween

What is DOTween?

According to the article published on their official website

A free and open-source, object-oriented animation engine for Unity users, developed in C#, optimized, with tons of advanced features, fast, efficient, completely safe.

So, to summarize briefly, we can say that DOTween is an open-source and free animation class - library developed for Unity.


What is DOTween Good For?

With DOTween, we can create animations, effects, and many more things on Unity.

Although I mostly use it for UI design in my projects, depending on the game or project, I even occasionally use it in game mechanics. In fact, there was even a time I wrote almost an entire game with DOTween, and you can check out this link to see the project where I used DOTween for both mechanics and UI effects/animations.

So, as you understand, DOTween will make things easier for you and can be used in any area depending on your intended purpose. (Mainly for game animations and effects.)

DOTween Installation

You can use the DOTween plugin by downloading and importing it into your project either from its official website or from the Unity Assets Store.

DOTween - Official Website

DOTween - Unity Assets Store Page

Downloading from the Official Website

DOTween Official Website

DOTween Official Website


Adding via Assets Store

DOTween Assets Store

Unity Installation

DOTween Unity

First, if we added it via Assets Store, we select "Import."

DOTween Unity

Then in the next section, after clicking all once and making sure all are selected, we click the "Import" button.

DOTween Unity

If it imported without issues, a panel like this will appear. Click the "Open DOTween Utility Panel" section and continue.

DOTween Unity

A panel like this will appear, click the "Setup DOTween..." button here.

DOTween Unity

In the selection section that appears, choose whichever you want to use in your project and click the "Apply" button. If you haven't encountered any problems, it means DOTween has been successfully added to your project.

Using DOTween

Yes, now let's get to simple usage examples. I won't give too many examples because it's quite easy to use and I think you'll pick it up quickly.

If we want to move our object to a specific location at a specific time, we use the command "DOMove(Vector3 to, float duration, bool snapping)" for our object.
In our code line to use on our object, in our script:
 object.transform.DOMove(target position (Vector3), how long it will take (float));
it is used in this way.

Using ready-to-use functions with DOTween is this simple.
If we want to create our own tweens, it is used as "static DOTween.To(setter, float startValue, float endValue, float duration)".

For example,
string text;
void Start(){
  DOTween.To( () => visibleText, ( str ) => visibleText = str, "Hello World!", 5f );
}
it is used in this way.

DOTween Popular Functions

DOMove(Vector3 to, float duration, bool snapping) 
Allows our object to go from its current position to the specified target.

DORotate(Vector3 to, float duration, RotateMode mode) 
Allows our object to rotate to the specified angle.

DOFillAmount(float to, float duration)
This allows the Fill value in images we use in UI (when we select "Filled") to move between values of 0 and 1.

DOValue(float to, float duration, bool snapping = false)
Lets us change the value of value-receiving components like sliders.

To not make this post any longer, I didn't explain every function and tried to keep it as simple as possible.

You can review other DOTween functions and features from this link. If you have any questions, you can ask in the comment section below. Have a good day.