Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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,239
    Minor update 1.0.001
    • Updated the readme file to point to the new DOTween Utility Panel
    If you already downloaded v1.0.000 you can totally skip this one ;)
     
  2. cybervaldez

    cybervaldez

    Joined:
    Aug 16, 2014
    Posts:
    87
    AWESOME! Now I want it cozy in my asset store list :)
     
  3. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    I'm adding some examples to the package and will send it to the Asset Store tomorrow ^_^ I'm also almost finished with the first version of the Pro, yesyes (it will be a "growing asset")!
     
    OnePxl and cybervaldez like this.
  4. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392

    Thanks for your support, and sorry for my confusion.

    When I use HOTween in my other scene I get this error when I interrupt the tween and unexpected positions don't occur:
    HOTween : PlugVector3 is overwriting PlugVector3 for Sliding Elements (UnityEngine.Transform).localPosition
    UnityEngine.Debug:LogWarning(Object)
    Holoville.HOTween.Core.TweenWarning:Log(String, Boolean) (at
     
  5. SirStompsalot

    SirStompsalot

    Joined:
    Sep 28, 2013
    Posts:
    112
    Hey @Izitmee,

    I'm having an issue with DoScale; what I am trying to do is make an object scale by its center instead of its pivot (essentially a 3D version of this css from jsfilddle http://jsfiddle.net/jdniki/fvgDk/ ). What I end up with at the moment is an object that shrinks and grows to one corner.

    Is there any way to scale around the center of the objects bounds, so it "pulls in" rather than "shrinks to pivot"? Currently my workaround is a very sloppy moveto and scale; would prefer a different way.
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @gegagome OH then it's a different thing, I didn't realize you weren't killing the previous tween. Just call myTween.Kill to clear it and you'll have no issues creating the new one (DOTween doesn't have an overwrite manager like HOTween because of its string-less nature). Or even better store and reuse the same tween as I mentioned.

    @SirStompsalot No "scale around center" method for now sorry: DOTween just scales like Unity does, so it's all around the pivot. I might add it later though :p
     
  7. SirStompsalot

    SirStompsalot

    Joined:
    Sep 28, 2013
    Posts:
    112
    Ah, was worth a shot. Actually what I was able to do is programmatically change the pivot point, works grand now. Thanks!
     
    Last edited: Jan 4, 2015
  8. joe90

    joe90

    Joined:
    May 16, 2014
    Posts:
    12
    Congrats on v1.. Will definitely get the pro version.

    One question.. I often get after a code change "Can't add script behaviour DOTweenComponent. The script needs to derive from MonoBehaviour!", If I rerun without changing any code everything works? Any ideas? I doubt this is a specific DOTween issue.
     
  9. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Thanks! :)

    Uhmm that's very weird, never heard about it. Are you trying to add the DOTweenComponent to something yourself (it should only be used by DOTween's internal code - and by the way DOTweenComponent is actually a MonoBehaviour)? Can you post a snapshot of your Hierarchy when you get this warning?
     
  10. joe90

    joe90

    Joined:
    May 16, 2014
    Posts:
    12
    Yep... Let me see if I can strip down to the minimum to reproduce the issue.
     
  11. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Minor update 1.0.008
    • Submitted to the Asset Store for the first time (now waiting approval)
    • Updated readme and setup dialog
    This release is just to bring DOTween up to speed with the Asset Store version I just submitted :)
     
    Last edited: Jan 5, 2015
  12. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Made a video of our (Gaetano Leonardi, Luigi di Guida & me) Ludum Dare 31 game in action (by the way, we placed 17 overall, so sweet). Check out DOTween in action with the new Unity 4.6 UI and a S***load of strings, among other things :)

     
    cybervaldez likes this.
  13. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Where's DOTween on the UAS?

    I supposed it is waiting for approval, right?
     
  14. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Yup, can take up to a week, especially since this is a first submission and not an update.
     
  15. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Hmmm, is there a trick to initialize DOTween correctly?

    The Init-call doesn't seem to work in Awake() or Start() - only in OnEnable(). I have a lot of of scripts starting at OnEnable(), therefore it results in hunting down the scripts, where it initializes for the first time. It is possible to enforce the call by using the "Unity Script Execution Order" list, but that gets kinda messy...
     
  16. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Ricks You just have to call it before creating your first tween. It will work in Start and Awake as long as you don't have other tweens been created in other Start/Awake methods whose MonoBehaviours execute sooner. Consider that you can eventually change all the init settings at a later time using global options.
     
  17. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    You are right, it definitely works within the given methods. The error comes from the fallacy, that before any OnEnable() is called, *all* Awake() methods from *all* scripts in the scene will be executed - which is wrong o_O (therefore I wondered why it initialized in a later OnEnable() method rather than in Awake(). After all a Unity Script Execution Order issue.
     
  18. 39thstreet

    39thstreet

    Joined:
    Jan 30, 2012
    Posts:
    104
    Is there a document anywhere that outlines porting from HOTween to DOTween? Is there a series of Find Replace actions we can take on an older project? TIA!
     
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @39thstreet Nope, no document like that. Adding it to my todo list. Find Replace won't work because HOTween didn't have shortcuts so, while the API is relatively similar in concept, it needs to be rewritten manually. As a note, I replaced HOTween with DOTween in my game Goscurry, which used tons of tweens, and it took me around an hour.
     
  20. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    hello again

    I am trying to store the tween as a sequence and use it but something is giving me this error:
    NullReferenceException: Object reference not set to an instance of an object
    DG.Tweening.TweenSettingsExtensions.Append (DG.Tweening.Sequence s, DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/TweenSettingsExtensions.cs:379)
    FireworksSlider.Awake () (at Assets/Resources/Scripts/Numbers/FireworksSlider.cs:24)


    I feel it is my static method but I am not sure. Also where do I add menuSequenceIn.Kill() so tweens don't misplace the tweens?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using DG.Tweening;
    5.  
    6. public class FireworksSlider : MonoBehaviour
    7. {
    8.     public static bool isFireworksMenuOnScene = false;
    9.     static RectTransform fireworkSliderRect;
    10.     public static Vector2 f_in = new Vector2(-30f, 0f);
    11.     public static Vector2 f_out = new Vector2(50f, 0f);
    12.  
    13.     static GameObject fireworksControllerObject;
    14.     static FireworksController fireworksController;
    15.  
    16.     public static Sequence menuSequenceIn;
    17.     public static Sequence menuSequenceOut;
    18.  
    19.     void Awake ()
    20.     {
    21.         fireworkSliderRect = this.GetComponent<RectTransform> ();
    22.         fireworksControllerObject = GameObject.FindGameObjectWithTag ("FireworksObject");
    23.         fireworksController = fireworksControllerObject.GetComponent<FireworksController>();
    24.         menuSequenceIn.Append(fireworkSliderRect.DOAnchorPos (f_in, 0.5f, false));
    25.         menuSequenceOut.Append(fireworkSliderRect.DOAnchorPos (f_out, 0.5f, false));
    26.     }
    27.  
    28.     void Start()
    29.     {
    30. //        DOTween.Init (true, true, LogBehaviour.Verbose);
    31.     }
    32.  
    33.     public static void FireworksMenuExposer ()
    34.     {
    35.         if (!isFireworksMenuOnScene)
    36.         {
    37.             menuSequenceIn.Play();
    38. //            fireworkSliderRect.DOAnchorPos(f_in, 0.5f, false);
    39. //            DOTween.To(()=> f_out, x=> fireworkSliderRect.anchoredPosition = x, f_in, 0.5f);
    40.             FireworksBackgroundQuad.FireworksBackdrop();
    41.             fireworksController.InvokeRepeating ("FireworksOn", 0f, 1f);
    42.             MasterAudio.FadeBusToVolume("Master", 0.1f, 1f);
    43.         }
    44.         else
    45.         {
    46.             menuSequenceIn.PlayBackwards();
    47. //            fireworkSliderRect.DOAnchorPos(f_out, 0.5f, false);
    48. //            DOTween.To(()=> f_in, x=> fireworkSliderRect.anchoredPosition = x, f_out, 0.5f);
    49.             FireworksBackgroundQuad.FireworksBackdrop();
    50.             fireworksController.CancelInvoke("FireworksOn");
    51.             MasterAudio.FadeBusToVolume("Master", 1f, 1f);
    52.         }
    53.         isFireworksMenuOnScene = !isFireworksMenuOnScene;
    54.     }
    55. }

    Thanks
     
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @gegagome Hellow! menuSequenceIn and menuSequenceOut have NULL values in your code. Before using methods like Append/etc you have to assign a new Sequence to them by doing:
    Code (csharp):
    1. menuSequenceIn = DOTween.Sequence();
    2. menuSequenceOut = DOTween.Sequence();
    If instead you were initializing them from some other class, the problem is that inside Awake RectTransform might not yet be intiialized, so you end up creating a tween where fireworksSliderRect is NULL. It's better to use Start for that.
    Also, they contain only one tween, so there's no need to use a Sequence there and you can just use a regular tween? Sequences are useful when you add more than one tween to them.
    About Kill, I don't see any need to call it. You're using the exact same animation every time right? Then you can just add a SetAutoKill(false) to your Sequence (or Tween if you decide not to use Sequences) and reuse the same one over and over.
     
  22. blastone

    blastone

    Joined:
    Apr 7, 2009
    Posts:
    168
    Hi there.
    I am wondering how to get the game object that was used in a Callback.
    So I have an array of GameObjects I am tweening

    Code (CSharp):
    1. for (int i = 0; i < stars; i++)
    2.             {
    3.                 diamonds[i].SetActive(true);
    4.  
    5.                 // Set Animation for Each Star
    6.                 diamonds[i].transform.DOMoveY(1.2f, 0.5f).SetDelay( 0.25f+i * 0.25f ).OnComplete( ()=>ExplodeDiamond() );
    7.              }
    Now in the ExplodeDiamond function I want to explode the specific Game object, but I cant see a way to reference the source Game object. What do I pass in the lambda to be able to reference the GameObject that is being called.
     
  23. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hello DOTween
    Not sure what is going on with my tween. The same behavior occurs when I interrupt the active tweens; which is to say sceneButtons[2] gets exposed when it should be hidden. I even added SetAutoKill() but the desired effect isn't happening.

    Thanks thanks

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using DG.Tweening;
    6.  
    7. public class SceneMenu : MonoBehaviour
    8. {
    9.     public List<GenericMenuOptions> sceneButtons;
    10.     public bool isMenuExposed = false;
    11.     public GameObject numbersBasicControllerReference;
    12.     public GameObject abacusWireReference;
    13.     public GameObject fireworksBackdropQuadReference;
    14.  
    15. //    Sequence menuExposer;
    16.  
    17.     const float menuIconHeight = 81.7f;
    18.  
    19.     NumbersBasicController numbersBasicController;
    20.     AbacusWire abacusWire;
    21.     FireworksBackgroundQuad fireworksBackdropQuad;
    22.  
    23.     void Awake ()
    24.     {
    25.         numbersBasicController = numbersBasicControllerReference.GetComponent<NumbersBasicController> ();
    26.         abacusWire = abacusWireReference.GetComponent<AbacusWire> ();
    27.         fireworksBackdropQuad = fireworksBackdropQuadReference.GetComponent<FireworksBackgroundQuad> ();
    28.     }
    29.  
    30.     void Start()
    31.     {
    32.         MenuIconPositioner ();
    33. //        DOTween.Init (true, true, LogBehaviour.Verbose);
    34.     }
    35.  
    36.     public void LoadMap(string arg)
    37.     {
    38.         switch (arg)
    39.         {
    40.             case "Loader":
    41.             {
    42.                 GearIconRotator ();
    43.                 //            item.transform.DOScale(normalScale, 1f).SetEase(Ease.OutQuint);
    44.                 //            MasterAudio.PlaySound("Others", 7f, 1.0f, 0f, "LeftMenuSFX");          
    45.             }          
    46.             break;
    47.          
    48.             case "Main Menu":
    49.             {
    50.                 Application.LoadLevel (1);
    51.             }      
    52.             break;
    53.  
    54.             case "Fireworks":
    55.             {
    56.                 FireworksSlider.FireworksMenuExposer();
    57.             }
    58.             break;
    59.         }
    60.     }
    61.  
    62.     public void GearIconRotator()
    63.     {
    64.         if(!isMenuExposed)
    65.         {
    66.             sceneButtons[0].button.transform.DORotate(new Vector3(0f, 0f, -120f), 0.5f);
    67.             StartCoroutine("BelowGearIconExposer");
    68.             Debug.Log ("Pressed gear when " + isMenuExposed);
    69.         }
    70.         else
    71.         {
    72.             sceneButtons[0].button.transform.DORotate(new Vector3(0f, 0f, 0f), 0.5f);
    73.             StartCoroutine("BelowGearIconUnexposer");
    74.             Debug.Log ("Pressed gear when " + isMenuExposed);
    75.         }
    76.         isMenuExposed = !isMenuExposed;
    77.     }
    78.  
    79. //    public IEnumerator MenuIconsExposer()
    80. //    {
    81. //
    82. //    }
    83.  
    84.     public IEnumerator BelowGearIconExposer()
    85.     {
    86.         for (int i = 1; i < sceneButtons.Count; i++)
    87.         {
    88.             sceneButtons[i].buttonRect.DOAnchorPos(sceneButtons[i].exposedPosition,
    89.                                                     0.25f,
    90.                                                     false)
    91.                 .SetAutoKill(false);
    92.             yield return new WaitForSeconds(0.25f);
    93.         }
    94.     }
    95.  
    96.     public IEnumerator BelowGearIconUnexposer()
    97.     {
    98.         for (int i = sceneButtons.Count - 1; i > 0; i--)
    99.         {
    100.             sceneButtons[i].buttonRect.DOAnchorPos(sceneButtons[i].unexposedPosition,
    101.                                                   0.25f,
    102.                                                   false)
    103.                 .SetAutoKill(false);
    104.             yield return new WaitForSeconds(0.25f);
    105.         }
    106.     }
    107.  
    108.     void MenuIconPositioner()
    109.     {
    110.         for (int i = 1; i < sceneButtons.Count; i++)
    111.         {
    112.             float temp = sceneButtons[i - 1].buttonRect.anchoredPosition.y - menuIconHeight;
    113.             sceneButtons[i].exposedPosition = new Vector2(45f, temp);
    114.             sceneButtons[i].unexposedPosition = new Vector2(-45f, temp);
    115.             sceneButtons[i].buttonRect.anchoredPosition = sceneButtons[i].unexposedPosition;
    116.         }
    117.     }
    118.  
    119.     void Update()
    120.     {
    121.         if (Input.GetKeyUp("q"))
    122.         {
    123.             FireworksSlider.FireworksMenuExposer();
    124.         }
    125.     }
    126. }
     

    Attached Files:

  24. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @blastone You don't need lambdas at all for callbacks that don't require any parameter:
    Code (csharp):
    1. .OnComplete(ExplodeDiamond)
    If instead you want to pass the gameObject as a parameter, that's when lambdas come in play, and you just pass it to the function like this:
    Code (csharp):
    1. .OnComplete(()=>ExplodeDiamond(diamonds[i]))
    2. // Somewhere else...
    3. void ExplodeDiamond(GameObject diamond) { ... }
    @gegagome Hey can you send me an updated stripped version of your current project, so I can fix it manually and show you what I had in mind? Will be much easier :)
     
  25. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Thank you so much.

    I've PM with link to project.

    Anxious to know what's going on with my tweens.
     
  26. Adam2Marsh

    Adam2Marsh

    Joined:
    Mar 2, 2014
    Posts:
    5
    Good Evening All,

    Having some issues getting the DoFade to work on a text Element in Unity 4.6 UI. I keep getting the following error:
    I've checked and I'm using the latest Unity and DoTween; performed a reinstalled and did clicked the Setup Button.

    I've tried a few different ways but the DoFade shortcut doesn't seem to work, I've tried the following:

    Code (CSharp):
    1. usingUnityEngine;
    2. usingSystem.Collections;
    3. usingDG.Tweening;
    4.  
    5. //First Attempt
    6. public GUIText gameStateText;    
    7.  
    8. public void ZombieTurnText () {
    9.    gameStateUI.guiText.text = "Zombie's Turn ";
    10.    gameStateUI.SetActive (true);
    11.    gameStateText.DoFade (0, 1f);
    12. }
    13.  
    14. //Second Attempt
    15. public GameObject gameStateUI;
    16.  
    17. public void ZombieTurnText () {
    18.    gameStateUI.guiText.text = "Zombie's Turn ";
    19.    gameStateUI.SetActive (true);
    20.    gameStateUI.guiText.DoFade (0, 1f);
    21. }
    I'm pretty sure its something I'm doing wrong, just not sure what. Tried searching but couldn't find any examples.

    Could someone lend a hand and point me in the right direction?

    Thanks in Advance,
    Adam
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi @Adam2Marsh,

    GUIText is not part of the new Unity 4.6 UI, but of the old one. If you want to use DOFade you should use the 4.6 Text object (which is also much much better than the old one - plus, combining the two different UI systems, the old one and the new, is definitely not recommended) :)

    P.S. if you really want to use a GUIText, you can always use DOTween's generic way:
    Code (csharp):
    1. DOTween.To(()=> gameStateUI.guiText.color, x=> gameStateUI.guiText.color = x, myNewColor, 1f);
     
  28. Adam2Marsh

    Adam2Marsh

    Joined:
    Mar 2, 2014
    Posts:
    5
    @Izitmee

    Thanks Mate, knew it was something simple just couldn't find the answer! Thanks for your help and DOTween! It's awesome! :)
     
  29. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Hi.

    I have been experimenting DOTween with 2dtoolkit.

    How can I tween sprite's color value?

    I can only find way to tween alpha.

    Color property is like

    tk2dsprite.color

    color = Color class;

    I also want to do it "from this color" -> "to this color"

    not just from my current color to my target color

    Thanks.
     
  30. tawsm

    tawsm

    Joined:
    Nov 12, 2013
    Posts:
    43
    Hi there,
    I'm using DOTween and i get these errors:
    DOTween.png
    And ideas why this happens? Ever had the same problem?
     
  31. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @castor76 Hiya! There are no shortcuts for 2D Toolkit (but I'm implementing them in the coming-soon Pro version) so you'll have to use DOTween's generic way. Color can be modified like this:
    Code (csharp):
    1. // Full color (Color endValue)
    2. DOTween.To(()=> tk2dsprite.color, x=> tk2dsprite.color = x, Color.yellow, 1);
    3. // Alpha only (float endValue)
    4. DOTween.ToAlpha(()=> tk2dsprite.color, x=> tk2dsprite.color = x, 0.5f, 1);
    @tawsm Hi! Can you select on of those errors (so it will show the full error tree in the lower half of the console) and send another screenshot? Also, how many tweens are you using? This will probably be solved simply by setting the max tweens at a higher level, but it's still a bug that I'd like to investigate, because DOTween should (and does in all my tests) raise the max allowed tweens automatically.
     
  32. tawsm

    tawsm

    Joined:
    Nov 12, 2013
    Posts:
    43
    Hi demigiant,
    thx for the quick reply, i realised it was some fault in my code. I am no programmer, so i'm still not quite sure what causes the issue... this is my code, the yellow code is what unity highlights me within the error.
    Do you still need the detailed error? My unity always crashes entirely, so i prefer not to reproduce the issue, until i fixed my code :p
    DOTween error.PNG
     
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    I apologize but yes, I would still need the detailed error (because it's related to code inside DOTween's DLL, so the true error line is shown only inside the detailed log). Still, can you try adding this line inside moveNewsText, right BEFORE the yellow line?
    Code (csharp):
    1. DOTween.SetTweensCapacity(2000, 1000);
    This should fix the error. But if you feel brave enough, it would be great if you managed to un-fix it then and get that detailed screenshot, so I can fight the demonic bugs and make sure this doesn't happen again :D
     
  34. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok, cool, but how do I set it up so it goes from Color to Color, not just from current ont to to target Color?

    I can set the color to my start color manually, before calling tween to play, but I was wondering if there is way to do From color => To Color using generic way.
     
  35. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Beautiful!

    It works!

    That's crazy simple. I was completely unaware of:
    sequenceName = DOTween.Sequence ().SetAutoKill (false).Pause ();
    Obviously I didn't know how to init a Sequence and its settings.

    And sequenceName.Insert is super nice. What I get Insert() does is record a specific tween so it is scheduled, without overlapping, or need for an external WaitForSeconds() like I did. I guess you can also Append() those tweens too but they won't be nicely tweened—Or scheduled (one after the other).

    Thanks
    German
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @castor76 Actually, the generic way is the only way you can do that, because shortcuts only work from the current value's position. So, to set a fixed starting color with the generic way, you just change the first lambda to return the color you want (beware, this only works with DOTween.To methods, not with DOTween.ToAlpha)
    Code (csharp):
    1. DOTween.To(()=> Color.cyan, x=> tk2dsprite.color = x, Color.yellow, 1);
    @gegagome Glad you enjoyed it :) I could've indeed used Append in your code, but went with Insert because those tweens in the for loop actually needed to overlap with the first one (the one that makes the menu button rotate). If I used Append they would've been added AFTER the rotation had finished. This way instead they play together with it.
     
  37. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Congrats on the Asset Store release, can't wait for the Pro version!
     
  38. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Congrats!!!
     
  39. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
  40. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Ok, there is an issue I encountered - not necessarily a bug, but not clear when using it:

    When I use DOTween.Clear() all Tweens are clear, however - the DOTween object remains in the scene. When I then execute a new Tween, a new DOTween object is added to the scene, although the old one is still here. When I then start a new Tween - it runs at double speed. It's like both instances run the tween. The more often you call Clear(), the more instances you'll get in your scene and the faster the tweens get, until you have lightspeed tweens.

    Another problem I had was this: because the DOTween isn't destroyed, it sometimes (not always, but sometimes!) goes over to the next scene when using Application.LoadLevel(). I don't know why this is the case and it's difficult to reproduce. But it happens occasionally and causes a MissingReferenceException. Now I have solved this by simply destroying all possible DOTween objects in Awake() when loading a new level, but if you don't know that, it can cause headaches.
     
    Last edited: Jan 10, 2015
  41. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Ricks OHMYGOD that IS a bug! And one that sometimes users had but then it disappeared and they never mentioned Clear so I never managed to reproduce it. I'm going to investigate it immediately, thanks for the report. In the meantime, you can call
    Code (csharp):
    1. DOTween.Clear(true);
    to completely clear DOTween, instance included.

    After I fix that, calling Clear without any other parameter should remove everything but correctly leave the DOTween gameObject, also carrying it to other scenes so it's ready when needed. But other DOTween instances shouldn't appear.
     
  42. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Ricks Upon further investigation, I can't replicate the "clear and duplicate" issue. DOTween.Clear works perfectly here, and if you recreate a tween no other DOTween instances are generated. Can you manage to replicate it in a barebone project and send it to me? That would help a lot.
     
  43. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Wait... this is totally confusing...

    I called DOTween.Clear(someObject.transform) - which shouldn't work anyways, because it should only accept true/false.

    That must be the error, that I can call Clear(someTransform) without warning, causing the duplicate bug.

    Edit: ok, I will try to reproduce this double error in a small project, or otherwise something must be badly wrong in my project.
     
    Last edited: Jan 10, 2015
  44. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Ricks nono that is a simple conversion happening in the background. If you use an object reference in place of a boolean, C# will convert it to "reference exists = TRUE", "reference is null = FALSE". I even tried that but everything is still working here.

    P:S. if you just want to remove the tweens of an object (as long as the tween was created with shortcuts) you should use Kill not Clear:
    Code (csharp):
    1. DOTween.Kill(someObject.transform);
    2. // or
    3. someObject.transform.DOKill();
     
  45. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Ah, I c. It's just because Kill() produced another issue (which I need to reproduce as well), so I randomly tried Clear() instead.

    However I have created a small project which will duplicate the DOTweens:

    A cube slowly tweens from left to right and back. When you press the GUI button multiple times, multiple DOTween instances are created. When you press the button the 1st time the cube slows down (logical, because it's closer to the target), when you press the button a 2nd time the cube is suddenly faster (not logical, because it's even closer to the target).

    Maybe it's a time issue, so the Clear() or Kill() isn't fast enough to kill everything before creating a new Tween, or it's because the same Tween reinitializes multiple times afterwards (once for every DOTween instance). Also note that the instance only duplicates every 2nd time the button is pressed.
     

    Attached Files:

    Last edited: Jan 10, 2015
  46. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Thank you very much Ricks. Going to lunch now but I'll check it immediately after that.

    (Clear and Kill happen instantly, so it can't be an execution speed problem, but I'll find it :))
     
  47. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Ricks Fixed :) Please check the attached v1.0.010 version with your full project too, so we can confirm this from all sides.
     

    Attached Files:

  48. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    @Izitmee Thanks! Tested it in both projects and found no other issues. I believe it was the same reason when changing scenes, that maybe a duplicate ghost instance remained.

    (PS: the so called Kill-issue I briefly mentioned is not a bug, I just forgot to add object.transform and the false parameter... very easy to make these errors). Now my project is successfully ported from iTween to DOTween.
     
  49. AlfonsoC

    AlfonsoC

    Joined:
    Oct 1, 2014
    Posts:
    27
    Hi this is awesone, before know about DOTween i used animations for my UI... but the starts always are complicated and i have some problems with a event in a sequence, i put the code if anyone knows what is happening y will glad the help..

    Code (CSharp):
    1.    
    2. void MoveFreeBanner(RectTransform b, float to, bool bb)
    3.     {
    4.         Sequence mySequence = DOTween.Sequence();
    5.         mySequence.Append(b.DOAnchorPos(new Vector2(0,to), .5f))
    6.                 .AppendInterval(3f)
    7.                 .Append(b.DOAnchorPos(new Vector2(0,50), .5f))
    8.                 .OnComplete( delegate {bb = true;});
    9.     }
    10.     public void TestAction()
    11.     {
    12.         if(boolBanner1)
    13.         {
    14.             boolBanner1 = false;
    15.             MoveFreeBanner(Banner1, 0, boolBanner1);
    16.         }
    17.         else if(boolBanner2)
    18.         {
    19.             boolBanner2 = false;
    20.             MoveFreeBanner(Banner2, -50, boolBanner2);
    21.         }
    22.         else if(boolBanner3)
    23.         {
    24.             boolBanner3 = false;
    25.             MoveFreeBanner(Banner3, -100, boolBanner3);
    26.         }
    27.         Debug.Log (boolBanner1);
    28.         Debug.Log (boolBanner2);
    29.         Debug.Log (boolBanner3);
    30.     }
    The main idea is for a notification popup with 3 maximum popup, the boolBanner is a flag to know if a banner is free to show or is in use now.. my problem is that the first 3 notification work well but it's seen that didnt do the OnComplete event.

    i try with lambda and with a external method but nothing work.

    thanks in advance and congratulations
     
  50. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    NEW UPDATE 1.0.010
    • Fixed DOTween component being duplicated in scene (and thus causing tweens to run twice as fast) when calling Clear and starting a new tween at the same time


    @Ricks great! Released it officially then! Thanks a lot for the help: you made me very happy. That was a bug that sometimes popped up but I never managed to replicate, so I always thought I fixed it in later versions. Glad it's finally out of the way.

    @AlfonsoC In C# when you pass a bool you can't pass it as a reference. Meaning that when you set bb to true you're only setting it inside that local function, while boolBanner1/2/3 are never changed. You will need to do something like this instead:
    Code (CSharp):
    1. void MoveFreeBanner(RectTransform b, float to, int bbId)
    2. {
    3.     Sequence mySequence = DOTween.Sequence();
    4.     mySequence.Append(b.DOAnchorPos(new Vector2(0,to), .5f))
    5.             .AppendInterval(3f)
    6.             .Append(b.DOAnchorPos(new Vector2(0,50), .5f))
    7.             .OnComplete( delegate {
    8.                 switch (bbId) {
    9.                 case 1:
    10.                     boolBanner1 = true;
    11.                     break;
    12.                 case 2:
    13.                     boolBanner2 = true;
    14.                     break;
    15.                 case 3:
    16.                     boolBanner3 = true;
    17.                     break;
    18.                 }
    19.             });
    20. }
    21.  
    22. public void TestAction()
    23.     {
    24.         if(boolBanner1)
    25.         {
    26.             boolBanner1 = false;
    27.             MoveFreeBanner(Banner1, 0, 1);
    28.         }
    29.         else if(boolBanner2)
    30.         {
    31.             boolBanner2 = false;
    32.             MoveFreeBanner(Banner2, -50, 2);
    33.         }
    34.         else if(boolBanner3)
    35.         {
    36.             boolBanner3 = false;
    37.             MoveFreeBanner(Banner3, -100, 3);
    38.         }
    39.         Debug.Log (boolBanner1);
    40.         Debug.Log (boolBanner2);
    41.         Debug.Log (boolBanner3);
    42.     }
    43.