Demigiant Forum

Unity Assets => DOTween & DOTween Pro => Topic started by: Leetful on March 30, 2016, 03:21:41 PM

Title: Tween overwriting
Post by: Leetful on March 30, 2016, 03:21:41 PM
Hi, question about overwriting tweens.

Wanted to confirm that tween 'overwriting' isn't a feature that already exists. For example, using scripts I've applied DOTWEEN to handle animation between different states of gameobjects (such as a mouse over/out). The problem is that applying an animation can come into conflict with those that are not yet complete -- so the previous animation has to be explicitly killed before applying the new one when it affects the same properties.

Is there a simple built-in way to combat this? My current less-than-ideal solution is using another layer of code above DOTWEEN to handle setting animations, which kills previous ones itself.
 
Title: Re: Tween overwriting
Post by: Daniele on March 30, 2016, 03:28:01 PM
Hi,

I have to confirm there's no overwrite in DOTween. Its previous version, HOTween, had it, but I decided not to implement it in DOTween because the only way to have it is to use Reflection, and I wanted to avoid any of it this time (mainly for performance reasons).

Consider though that you don't need to kill a tween in order to allow an overlayed one to play: you can just pause it.

Cheers,
Daniele
Title: Re: Tween overwriting
Post by: Leetful on March 31, 2016, 02:53:24 PM
Thanks for the info.

Related question, is there a convenient way of updating an existing tween (either in-progress or after it's finished) with a new set of animation properties and re-running it without creating a new tween and having to pause/kill the last?
Title: Re: Tween overwriting
Post by: Daniele on March 31, 2016, 03:08:23 PM
You could either use ChangeValues (http://dotween.demigiant.com/documentation.php?api=ChangeValues), or depending on the settings you want to change you could just chain them again and they will overwrite the previous ones (most chained settings (http://dotween.demigiant.com/documentation.php#options) can be applied at any time).

Also, in case of the same animation playing forwards or backwards (like a button press or a UI element entering/exiting), I usually just use the same tween (with SetAutoKill to false) and use PlayForward/PlayBackwards to switch its direction.