Search Unity

DOTween (HOTween v2), a Unity tween engine

Discussion in 'Assets and Asset Store' started by Demigiant, Aug 5, 2014.

  1. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    I wanted to say exactly what @Baroni said :) SWS can do all you said except for the third point, but I'm implementing caching already in DOTween (which SWS will implement when I finally finish it) :)
     
    Baroni likes this.
  2. Kiori

    Kiori

    Joined:
    Jun 25, 2014
    Posts:
    161
    You should make a new benchmark of DOTween against DFTween, they are going around boasting to be the fastest one in town.
    Also, if you do release a pro version with visual editing of the paths and the tweens, etc., count me in as a buyer,
     
    OnePxl and MrEsquire like this.
  3. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    I didn't know of DFTween when I made the comparisons so that's why it's not there. Will try to see how it compares as soon as I have the time, and thanks :)
     
  4. ChenTotal

    ChenTotal

    Joined:
    Nov 24, 2014
    Posts:
    2
    Hi,
    I got a problem that using DOScale with Ease.
    Code (CSharp):
    1. float textDuration = 1.5f;
    2. float iconScalelDuration = 0.5f;
    3. Vector3 bigScale = new Vector3(1.2f, 1.2f, 1.0f);
    4. Vector3 smallScale = new Vector3(1.0f,1.0f,1.0f);
    5. DOTween.Sequence()          
    6. .Append(m_GoldIcon.transform.DOScale(bigScale, iconScalelDuration).SetEase(Ease.InElastic))
    7. .Append(m_GoldIcon.transform.DOScale(smallScale, iconScalelDuration).SetEase(Ease.OutElastic));
    m_GoldIcon is a tk2dSprite.
    My problem is that when m_GoldIcon is scaling to smallScale, it would scale to around 2.0f(x,y) during the processing.
    Is that correct result or do I use it wrong??
    Thanks
     
  5. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @mlabarca I tested your tween with Unity 4.6 and an Image element. Everything works perfectly here. Are you sure that Unity hadn't semi-crashed on you (a thing that happens sometimes, where everything still works but kind of stutters) and that's why you were having the stutter issue?

    @ChenTotal Elastic tweens scale beyond the the end value and sometimes even beyond the start value, so yes it's the correct result. If you don't want your tween to scale beyond your start/end value you should use an ease other than Elastic/Back/Bounce.
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Kiori DFTween comparison made, though DFTween documentation is kind of lacking so I kind of roughed it up using some examples. Apparently DOTween is slightly faster when tweening Transform objects and such, is slightly slower with floats and such, and has a general faster startup time than DFTween. Also consider that DOTween offers more features from what I could see ;)
     
  7. Kiori

    Kiori

    Joined:
    Jun 25, 2014
    Posts:
    161
    And there you have it, so much for all the blah.
    Again eagerly awaiting your gui solution and the pro pkg.
     
    OnePxl likes this.
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Glad you're waiting for the pro :) And it must be said about DFTween that it seems like a nice engine (even if it would need better documentation). We're all open-source devs that make free assets (sometimes with pro versions, but still), so I suppose we're all mates and rivalry makes no sense ;) (except when someone copy-pastes your code to make another tween engine, but that's in the past)
     
  9. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Humbug. DOTween is king!
     
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
  11. byerdelen

    byerdelen

    Joined:
    Mar 27, 2010
    Posts:
    68
    DoTween is wonderful, now I can switch from Itween! among many things this is the reason I loved :
    Code (CSharp):
    1. yield return transform.DOLocalMove(new Vector3(2, 8, 9), 1).WaitForCompletion();
    In need of a quick coroutine, a short line solves all my problems.

    It is not stated in documentation but just to confirm:
    Is there a way to write smt like that(shortcut extention):
    Code (CSharp):
    1. val.DOTo(5, 1);
    Instead of the generic one:
    Code (CSharp):
    1. DOTween.To(() => val, x => val = x, 5, 1);
    So I can remember one way and apply it everywhere.

    Thanks for this wonderful library
     
  12. dmko

    dmko

    Joined:
    Jun 15, 2014
    Posts:
    65
    Question, consider a button that toggles a tween one way or another. Will the new ones cancel the previous ones per type?

    i.e. if it started a DoMove and DoRotate, and then began a new DoRotate, will the previous DoMove continue to process? Will the previous DoRotate fight the new DoRotate somehow? Is the workaround to call a DoKill() and then DoMove(with old values) + new DoRotate() ?
     
  13. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @byerdelen Very happy you like it, and glad you enjoyed the coroutine methods, since no one mentioned them until now and I thought I was the only one liking them :D I can confirm that val.DOTo doesn't exist: floats/ints are structs so that simply wouldn't be possible.

    @dmko There is no OverwriteManager in DOTween (because of its architecture), so two tweens running at the same time on the same object wouldn't cancel each other: they would simply "fight" each other instead. I recommend to either Kill the old one, or simply Pause and reuse it when it's time.
     
  14. Umai

    Umai

    Joined:
    Jun 18, 2013
    Posts:
    74
    SetParent(null) does not work within OnComplete.. it seems. The transform is not removed from parent, at least the label is still visible. Known issue, or my mistake somewhere?

    Code (CSharp):
    1. foreach (RectTransformrecttransformLabelinthis.nodeForresultsummary.transform) {
    2. if (recttransformLabel != recttransformLabellast) {
    3. DOTween.Sequence() //http://dotween.demigiant.com/documentation.php
    4. .Append(recttransformLabel.DOMove(TARGET, 0.5f * AF))
    5. .OnComplete(() => {
    6. Debug.Log("Remove from parent: " + recttransformLabel);
    7. recttransformLabel.SetParent(null);
    8. });
    9. }
    10. }
     
  15. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Umai Setting a parent to NULL doesn't make the transform invisible (as you seem to assume when expecting the label to disappear, from what I understand :p).
     
    Umai likes this.
  16. gpvd

    gpvd

    Joined:
    Nov 2, 2013
    Posts:
    78
    Hello Izitmee,

    I'm a little confused about speedbased duration AND ease setting other than Linear;

    Is it possible to start speed with any value (E.g. start speed with 5) and end at given value (E.g. 12), using easing?
    Or starts easing always with value 0?

    Tnx in advance,
    Greetz,
    G
     
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @gpvd

    It may be a little confusing indeed: that's why I didn't allow any ease other than Linear with SpeedBased and HOTween. But some users asked for them so I implemented them in DOTween.

    In short. using Linear ease will maintain the speed constant for all the tween duration. Using any other ease will cause the tween to last exactly as with a Linear SpeedBased duration, but will accelerate/decelerate while animating depending on the ease. All "In" eases (like InQuad, InQuint, etc) start with a value of 0.
     
  18. gpvd

    gpvd

    Joined:
    Nov 2, 2013
    Posts:
    78
    Now it's less confusing!
    Is it possible then to add an option to give a starting ease value instead of always start with 0?
     
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    The starting value is a preset that depends on the type of ease you use ("In" eases have a value of 0, while "Out" eases have a "max speed" value). But you can also use custom AnimationCurves and pass them as eases, so you can set the speed change you prefer :)
     
  20. gpvd

    gpvd

    Joined:
    Nov 2, 2013
    Posts:
    78
    Ok,
    I'll use AnimationCurves then.

    Tnx again for the quick response!

    Greetz,
    G
     
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    You're welcome :) Greetz!
     
  22. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Is there something one should consider tweening RectTransforms/the new UI Elements?
     
  23. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    DOTween46! You mean that? There are already some shortcuts for the new UI implemented, but if you want more just let me know ;)
     
  24. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Nah, I had just some problems tweening a simple UIImage to another one with .DOLocalMove:

    Code (CSharp):
    1. public class TweenTest : MonoBehaviour
    2. {
    3.     public RectTransform uiRect;
    4.     public RectTransform dest;
    5.  
    6.     // Use this for initialization
    7.     void Start()
    8.     {
    9.         uiRect.DOLocalMove(dest.localPosition, 1.0f, false);
    10.     }
    11.  
    12. }
    This is the Hierarchy:



    The Object "Container" which is child of "TOPLEFT" has the script and it's own RectTransform is the "uiRect" from the script. The "dest"-RectTransform is the "TweenDestination"-UIObject.

    So, when I start the uiRect does not tween to the (pivot)Position of "TweenDestination", instead it tweens to this position:

     

    Attached Files:

  25. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @BTStone You're tweening one localPosition to another localPosition with objects that have different parents. I suppose the localPosition of TweenDestination is 0,0, and so TOPLEFT goes to its own local 0,0 which is the top left corner of the canvas (from what I understand). You should use:
    Code (csharp):
    1. uiRect.DOMove(dest.position, 1.0f, false);
    or use Transforms that have the same parent and the same set of local coordinates :p
     
  26. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Oh boy. I changed dest.localPosition already to dest.position and it still tweened in a weird way.
    Totally forgot to change DOLocalMove to DOMove. Everything's fine. Thanks ;)
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
  28. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Since I made another game (with 5 other friends) that uses DOTween, I'm shamefully posting it here. It was made in 3 days for the Game Jolt #indiesvspewdiepie jam, so if you like it please leave us a vote here ;)

    bladesque_hl.png

    PLAY IT ON GAME JOLT

    Made by:
    • Michele Pirovano - Project lead, code, game design
    • Renato Mainetti - Code, game design, swords
    • Daniele Giardini (moi :p) - UI design, UI code, cards
    • Gaetano Leonardi - Character design
    • Luca Eberhart - Environment design
    • Luigi di Guida - Music and sound
     
    YaVeTaL and smitchell like this.
  29. Umai

    Umai

    Joined:
    Jun 18, 2013
    Posts:
    74
    Thanks... "unparenting" in most other hierarchy systems has the effect that the item goes invisible... like UIKit, Cocos2D, XML ;-) I learn new stuff about Unity everyday...
     
  30. gpvd

    gpvd

    Joined:
    Nov 2, 2013
    Posts:
    78
    Hello Izitmee,

    a question, right now i have many tweens running; However i see that some tweens are paused unintentionally.
    Is there any way to get info on which tweens are paused?
    At the moment there is no callback OnPause(). That could come in handy when debugging?

    Tnx in advance,
    Greetz,
    G
     
  31. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
  32. gpvd

    gpvd

    Joined:
    Nov 2, 2013
    Posts:
    78
  33. fermmmm

    fermmmm

    Joined:
    Oct 18, 2013
    Posts:
    129
    Hi Demigiant
    When I set SetLoops to 1, OnStepComplete gets executed and I found this a bit confusing since OnStepComplete should be something related to a looping Tween, but SetLoops is 1 so it's not a looping tween. I think OnStepComplete should be executed only if SetLoops is > 1, is my opinion, maybe you should ask other people
     
  34. Aslan85

    Aslan85

    Joined:
    Feb 24, 2014
    Posts:
    14
    Hi Daniele,

    They have a way to ignore the unity's global time scale ?

    In my project, I create a simple "Pause Menu". When the player click on the pause button, I use "Time.timeScale = 0" to block the game and I display a "Pause Text". I want a simple blink on this text.

    So, I use this code :
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using DG.Tweening;
    5.  
    6. public class txtPause : MonoBehaviour {
    7.  
    8.     Image target;
    9.     float animationTime = 1f;
    10.  
    11.     void Awake(){
    12.         target = gameObject.GetComponent<Image> ();
    13.     }
    14.  
    15.     void Start (){
    16.         DOTween.To (() => target.color, x => target.color = x, new Color (1, 1, 1, 0), animationTime )
    17.             .SetOptions (true)
    18.             .SetLoops (-1, LoopType.Yoyo);
    19.     }
    20. }
    But if the unity's time scale is at 0, the blink does not work.
    Also, if in the option, I use "myTween.timeScale = 1f;" or if I set "DOTween.timeScale = 1f;" that does not work.

    Do you have a solution ?

    Thanks
     
  35. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hiya @fermmmm, a Step is considered a single loop cycle, and in tween engines even something that plays only once is usually considered as having 1 loop cycle versus having none. The reason behind that is to make loop counting more clear, so that a tween which plays twice will be considered as having 2 loop cycles and not 1, which would be otherwise confusing. So OnStepComplete happens every time a single loop cycle ends, even if there is only one :)

    @Aslan85 Sure you can :) The second optional parameter of SetUpdate allows you to choose if the tween should be timeScale-independent (TRUE) or not (FALSE).
     
  36. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    How would I go about creating a "circle" like tween? I would like my background to move around in a circular motion, not rotating but moving its position around in a circle.
     
  37. Aslan85

    Aslan85

    Joined:
    Feb 24, 2014
    Posts:
    14
    #535 = Thank you. That's work perfectly !
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @mimminito Well the best way to do a perfect circle would be a trick. Place your object inside an empty gameObject, with a distance from its center equal to the radius you want, and rotate the container :p
     
  39. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Oldest trick in the book. :D
     
  40. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
  41. DanSuperGP

    DanSuperGP

    Joined:
    Apr 7, 2013
    Posts:
    408
    I just downloaded DoTween because I heard it's the best and fastest tween library for Unity and that iTween (which I've been using forever) is actually terrible.

    So far it looks great, but I'm trying to do something complicated and I was hoping you could give me a gentle nudge in the right direction.

    I want to start a tween to rotate a game object X degrees (around the z axis) and have it fire an event every (y) degrees of rotation.

    It looks like I could do this using the Sequence functionality, but I don't want it to hitch, and I want it to slow-in and slow-out only at the beginning and end of the rotation.

    Any advice on how to set this up?
     
  42. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @DanSuperGP , glad to have you on board :)

    if you want to fire events every N time, you can Insert callbacks and a single tween in your Sequence, so the tween will be completely smooth and the callbacks will just fire while it plays.

    Otherwise you could create various connected tweens (still inside a Sequence) with a Linear ease and a callback at the end of each, so even if they're separate tweens, as long the ease is Linear you won't notice when one ends and the other starts (DOTween is built to calculate time correctly in such cases and create smooth transitions).
     
  43. DanSuperGP

    DanSuperGP

    Joined:
    Apr 7, 2013
    Posts:
    408
    Hmm, I was thinking I could chain an ease In on the first one, linear for all the middle ones, and an ease out on the last one.

    I already found a solution that works involving a trigger collider and a single rotation tween that made the effect i want work, but I'm sure I'll find other uses for the sequence.

    So far (and it's only been a few hours) I'm really liking the way DoTween works, no messy Hashtables. I'm also very happy it's working with Unity5 beta on a Mac, you must have put some work into getting it ready for that.
     
  44. abar

    abar

    Joined:
    Jan 12, 2014
    Posts:
    72
    Any plans to add shortcuts for RectTransform properties?
    Specifically anchoredPosition/anchoredPosition3D are really useful to animate because it's what is displayed in the inspector as the position. sizeDelta would probably also be useful.
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @DanSuperGP Glad you're liking it :) And actually I don't have Unity 5, but I struggled to make a strongly compatible, other than fast, tween engine, and some nice users tested it on Unity 5 for me :)

    @abar I'm very open to shortcuts (just added shortcuts for Outline that will be in next release) since they're extremely simple to implement. I added RectTransform shortcuts to my TODO list, and please let me know what other ones you would find useful (I seriously used the 4.6 UI only this weekend for the first time, for Ludum Dare, so I still don't know all the goodies in it).
     
  46. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    P.S. another round of shameful self-promotion involving DOTween too. I went jam crazy and also made last weekend's Ludum Dare (theme: "Entire game in one screening"). I came out with The Screening, with graphics by Gaetano Leonardi and music by Luigi di Guida.

    If you're curious you can see/play it here.

    TheScreening_00.png
     
  47. abar

    abar

    Joined:
    Jan 12, 2014
    Posts:
    72
    Well, for animating the position/size of UI elements, then anchoredPosition, anchoredPosition3D and sizeDelta are probably the most important. Then the other property I commonly animate is the alpha on a CanvasGroup component.

    DOTween is awesome btw!
     
  48. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @abar Glad you like it :) And here you go, added DOSizeDelta, DOAnchor and DOAnchor3D for RectTransform objects (CanvasGroup.DOFade was already present ;)). I'll release it officially later this week, because I want to add a little more stuff first.
     

    Attached Files:

    DanSuperGP likes this.
  49. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hey there

    Just checking if it's possible to change the value of a UI Slider PosX using Dotween?

    Ideally I would love to hide this slider with a bool check and determine its visibility inside the scene.
     

    Attached Files:

  50. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @gegagome You mean Slider.value? You can already do that like this (but I'll add it to the todo list of shortcuts :)):
    Code (csharp):
    1. DOTween.To(()=>mySlider.value, x=>mySlider.value = x, endValue, time);