Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    The first thing to do would be to sit down and write some code to do that thing that you want to do.
    Then come back and tell us where you're having problems.

    Code (CSharp):
    1. //hint:
    2.     .SetLoops(-1);
     
  2. nkj79

    nkj79

    Joined:
    Jan 5, 2016
    Posts:
    2
    Thanks for the answer @FuguFirecracker. As I am new to programming, probably I couldn't explain the issue properly. I want my image to rotate continuously and without any break, like coin rotating endlessly. I tried following code and it is rotating and looping but I am not getting the desired performance, I can see slight jerks in the rotation (specially on mobile). Please note that this is the only line in my game, so no other performance/memory hogs.

    I am using Unity 5 GUI, canvas renderer, png texture. Am I missing anything here, to increase performance ?

    Code (CSharp):
    1. this.ring.transform.DORotate(newVector3(0, 0, 360), 2, RotateMode.LocalAxisAdd).SetLoops(-1).SetEase(Ease.Linear);
     
  3. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    cache that transform !
    You only need to look that up once... not continuously.
    ring.transform is a shortcut for ring.GetComponent<Transform>();
    well... it USED to be. they did some optimizations to it in Unity 5, but still not as fast as caching it.

    What size image are you trying to rotate?
    Does it reside on a sprite map?
    How many draw calls you got going on ?

    #EDIT ADDENDUM
    Also, setting a rotation to 360 can have unpredictable results... jumpiness even...
    try incrementally rotating.

    Code (CSharp):
    1. Transform _cachedTransform = this.ring.GetComponent<Transform>();
    2. float degrees = 90;
    3.        
    4. _cachedTransform.DORotate(Vector3.forward * degrees, 0.5f)
    5. .SetLoops(-1, LoopType.Incremental);
    6.  
    7. //Vector3.forward is shorthand for new Vector3(0,0,1)
    8. // Times it by the degrees you wish to rotate (90)
    9. // and you will do a full rotation every 2 seconds ( 4*0.5f== 2f)
     
    Last edited: May 17, 2016
  4. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hello there

    I have a question regarding TweenCallback. I need to pass arguments when chaining a tween using OnComplete.

    I got some errors when passing arguments using OnComplete with TweenCallbacks, so I was wondering if someone would know how to do it in this MoveLetter(float posX, float value) method:
    Code (CSharp):
    1. MoveLetter(-800f, 800f);
    2.  
    3.     public void MoveLetter (float posX) {
    4. //        Debug.Log("should move " + _aText.text + " to " + posX);
    5.         _aRectTransform.DOAnchorPosX(posX, BigLettersController.TWEENING_TIME, false)
    6.             .SetEase(Ease.InOutCubic);
    7.     }
    8.  
    9.     public void MoveLetter (float posX, float value) {
    10.         //        Debug.Log("should move " + _aText.text + " to " + posX);
    11.         _aRectTransform.DOAnchorPosX(posX, BigLettersController.TWEENING_TIME, false)
    12.             .SetEase(Ease.InOutCubic)
    13.             .OnComplete(()=> {
    14.                 _aRectTransform.anchoredPosition = new Vector2(value, 0f);
    15.                 MoveLetter(0f);
    16.             });
    17.     }

    Thanks
     
  5. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Copy and paste your error please.
    I'm gonna go out on a limb and say that this is not a DoTween issue.
    This is a "Recursive-Overloaded-Method-Using-Reserved-Value-Keyword-As-Parameter-Name" issue.
     
  6. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Oh sorry for the confusion.

    The code I pasted above doesn't produce an error. It works fine :)

    I just want to learn how to use OnComplete passing arguments: OnComplete(MethodName(args))

    I successfully passed a void method name as TweenCallback but again I couldn't figure how to pass arguments in the chain call.


    Thanks
     
  7. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Code (CSharp):
    1. .OnComplete(()=>
    2.    {
    3.     UseBraces(passAParameter);
    4.    }
    5. );
     
  8. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392

    Thanks
    My question is more like how to pass it as TweenCallback like this:
    Code (CSharp):
    1. transform.DOMoveX(4, 1).OnComplete(()=>MyCallback(someParam, someOtherParam));
     
  9. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    What is 'it' ?
    Please be more specific about what you're trying to do.

    The code I posted, and indeed the code you posted after, is how one passes arguments to a callback method.
    Those 'parameters' are arguments. Are you using the right terminology?

    You mentioned that you successfully passed a void method?
    Are you trying to get a return value from a method?

    Sorry, I don't know what the question is asking to resolve.
     
  10. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Unfortunately I couldn't find the resource but this is what I was trying to do:

    Code (CSharp):
    1. public void MoveLetter (float posX, TweenCallback callBack, float value) {
    2.     _aRectTransform.DOAnchorPosX(posX, BigLettersController.TWEENING_TIME, false)
    3.         .SetEase(Ease.InOutCubic)
    4.         .OnComplete(()=>callBack(value));
    5. }
    Notice how the class TweenCallback is used to pass a method as argument? Of that way I don't have to use a block, instead I can use any method I choose.

    Hope that clarifies what I am trying to do.

    Thanks FuguFirecracker

     
  11. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Any reply for my issue ? (some post above..) :p
     
  12. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    AHA!
    Understood.
    Use Unity Actions.
    You can even make it an optional parameter by having it be the last parameter and pre-assigning it the value of null

    Here's a realworld example I use to fire a method [or not] after my 2d camera has changed focus:

    Code (CSharp):
    1.  public void ZoomIn(float size, float speed, UnityAction action = null)
    2.         {
    3.             size = Mathf.Clamp(size, _minCameraSize, _maxCameraSize);
    4.  
    5.             _zoomTweener.Kill();
    6.  
    7.             _zoomTweener =
    8.            DOTween.To(() => MainCamera.orthographicSize, x => MainCamera.orthographicSize = x, size, speed)
    9.                 .SetEase(Ease.Linear)
    10.                 .SetAutoKill(true)
    11.                 .SetRecyclable(true)
    12.                 .OnComplete(() =>
    13.                 {
    14.                     if (action != null)
    15.                     {
    16.                         action();
    17.                     }
    18.                 });
    19.             _zoomTweener.OnUpdate(() => Control.Init.UISystem.Backdrop.ScaleIt());
    20.         }
    The above is called from an event and passing a lambda. In this case, I enable Touch Controls after my camera has zoomed in.

    Code (CSharp):
    1.   InPlayEvents.OnZoomIn(12.5f, 3.5f, () => Control.Init.TouchSystem.EnableTouch());
    You don't need to call it from an event, can call the ZoomIn method directly
    Code (CSharp):
    1. ZoomIn(size, speed, () => MyFancyMethod());
    2. // and the last parameter is optional
     
  13. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Quick question:

    What would be the best/smartest way to accomplish this behaviour:

    I want an object to move (DOMoveLocalX/Y/Z or simple DOMoveLocal) and while it moves from A to B I want it to shake with DOShakePosition. Now the shaketween should be played as long as the object moves, the moment it reaches B it should stop shaking.

    I'm thinking about using Sequences for this or using Callbacks but I'm not sure what would be the smartest way. Suggestions?
     
  14. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    Heya,

    Is this bug solved? https://github.com/Demigiant/dotween/issues/16

    This is a very critical issue for me, been getting this in Production version, analytics shows more than 40% of my users are getting this.

    If there some other way to solve it, would appreciate to know.

    Thanks
    Koby
     
  15. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Hello. Thank you for the great engine. I'm enjoying it a lot, however having some strange issue right now.

    This code doesn't work, and _worldRotationAnimated remains zero (0,0,0,1) :
    Code (CSharp):
    1. public class BattleCamera1 : MonoBehaviour
    2. {
    3.     [SerializeField]
    4.     private Transform _pivot;
    5.     [SerializeField]
    6.     private Transform _shipTransform;
    7.  
    8.     private Vector3 _worldRotationRaw;
    9.     private Quaternion _worldRotationAnimated;
    10.     //private Vector3 _worldRotationAnimated;
    11.     private Tweener _worldRotationTweener;
    12.  
    13.     void Start ()
    14.     {
    15.         _worldRotationTweener = DOTween.To(() => _worldRotationAnimated, x => _worldRotationAnimated = x, _worldRotationRaw, 0.4f);
    16.     }
    17.  
    18.     void Update ()
    19.     {
    20.         _worldRotationRaw = _shipTransform.rotation.eulerAngles;
    21.         _worldRotationTweener.ChangeValues(_worldRotationAnimated, _worldRotationRaw);
    22.         _worldRotationTweener.Restart();
    23.         //DOTween.To(() => _worldRotationAnimated, x => _worldRotationAnimated = x, _worldRotationRaw, 0.4f);
    24.         _pivot.rotation = _worldRotationAnimated;
    25.  
    26.         print(_worldRotationRaw);// Outputs correct values.
    27.         print(_worldRotationAnimated);// Outputs zero quaternion.
    28.     }
    29. }
    This one works but produces new tweeners which I'm trying to avoid:
    Code (CSharp):
    1. public class BattleCamera1 : MonoBehaviour
    2. {
    3.     [SerializeField]
    4.     private Transform _pivot;
    5.     [SerializeField]
    6.     private Transform _shipTransform;
    7.  
    8.     private Vector3 _worldRotationRaw;
    9.     private Quaternion _worldRotationAnimated;
    10.     //private Vector3 _worldRotationAnimated;
    11.     private Tweener _worldRotationTweener;
    12.  
    13.     void Start ()
    14.     {
    15.         _worldRotationTweener = DOTween.To(() => _worldRotationAnimated, x => _worldRotationAnimated = x, _worldRotationRaw, 0.4f);
    16.     }
    17.  
    18.     void Update ()
    19.     {
    20.         _worldRotationRaw = _shipTransform.rotation.eulerAngles;
    21.         //_worldRotationTweener.ChangeValues(_worldRotationAnimated, _worldRotationRaw);
    22.         //_worldRotationTweener.Restart();
    23.         DOTween.To(() => _worldRotationAnimated, x => _worldRotationAnimated = x, _worldRotationRaw, 0.4f);
    24.         _pivot.rotation = _worldRotationAnimated;
    25.  
    26.         print(_worldRotationRaw);// Outputs correct values.
    27.         print(_worldRotationAnimated);// Outputs correct values.
    28.     }
    29. }
    And this one works, but I cant find the way to make DOTween treat vectors as rotation so it goes crazy when values go from 360 to 0:
    Code (CSharp):
    1. public class BattleCamera1 : MonoBehaviour
    2. {
    3.     [SerializeField]
    4.     private Transform _pivot;
    5.     [SerializeField]
    6.     private Transform _shipTransform;
    7.  
    8.     private Vector3 _worldRotationRaw;
    9.     //private Quaternion _worldRotationAnimated;
    10.     private Vector3 _worldRotationAnimated;
    11.     private Tweener _worldRotationTweener;
    12.  
    13.     void Start ()
    14.     {
    15.         _worldRotationTweener = DOTween.To(() => _worldRotationAnimated, x => _worldRotationAnimated = x, _worldRotationRaw, 0.4f);
    16.     }
    17.  
    18.     void Update ()
    19.     {
    20.         _worldRotationRaw = _shipTransform.rotation.eulerAngles;
    21.         _worldRotationTweener.ChangeValues(_worldRotationAnimated, _worldRotationRaw);
    22.         _worldRotationTweener.Restart();
    23.         //DOTween.To(() => _worldRotationAnimated, x => _worldRotationAnimated = x, _worldRotationRaw, 0.4f);
    24.         _pivot.rotation = Quaternion.Euler(_worldRotationAnimated);
    25.  
    26.         print(_worldRotationRaw);// Outputs correct values.
    27.         print(_worldRotationAnimated);// Outputs values but behaves incorrectly.
    28.     }
    29. }
    Can you help me? Am I doing anything wrong?

    Also, a separate question: is it possible to avoid memory allocation with DOTween completely, if reusing preinstantiated tweeners?
     
    Last edited: May 24, 2016
  16. mikatu

    mikatu

    Joined:
    Aug 3, 2015
    Posts:
    28
    Make sure you have the latest version from http://dotween.demigiant.com/download.php
    The latest version fixed the problem in my case but looking at that Github-page there may still be some issues.
    If that doesn't help, see "index is out of range" under Errors in http://dotween.demigiant.com/support.php
     
  17. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    I using v1.1.260

    Tried DOTween.SetTweensCapacity(2000, 200);
    But the above exception still occours...

    Been also getting the following error:
    Code (CSharp):
    1. Exception: InvalidOperationException: Operation is not valid due to the current state of the object System.Collections.Generic.Stack`1[DG.Tweening.Tween].Pop () DG.Tweening.Core.TweenManager.GetSequence () DG.Tweening.DOTween.Sequence ()
     
  18. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I am trying to use DOTWEEN in console platform, and I need to know what dlls I can NOT have to load for a runtime usage.

    This is important because I need to reduce number of dlls that are being loaded in the start up of Unity engine for console platform.

    At the moment, I am using pro version so it loads dlls that seems like having names such as 43 , 46 , 50 , and pro etc..

    I am using Unity 5.3.4 so can't I just load 50 and maybe pro?
     
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Oh for f***'s sake. Ladies and gentlemen I am so sorry! Once again Unity forgot to send me notifications, and I was getting so many direct-mail support requests that I totally forgot to check the forums too. This is not the first time that it happens, so I'm practically unforgivable, but I hope you'll forgive me anyway. Not getting notifications is really messing with me (I have memory problems since always: nothing biggie, but I need to rely on notifications - will write Unity again and try to set a weekly alarm to check the forums too).
    In the meantime, big thanks to @JakeTBear and @FuguFirecracker for helping! You are my heroes! :)

    Here we go, trying to solve what was unsolved:
    @castor76 You definitely need the main DOTween.dll. The other ones are all related to specific features of each version. So for example DOTween46.dll has shortcuts for all the new features that were introduced in Unity 4.6 (like UGUI). DOTween50 only has shortcuts for Unity's new AudioMixer, so if you're not tweening it you could actually scrap that.

    Yes, that was solved indeed. but the fact you're getting it, and the Sequence bug, are new to me. Can you send me more info with full logs please? Write me via mail directly, so I can check it better (if you write me here we'll continue via mail).

    @illinar About rotations, you must use the additional RotateMode.FastBeyond360 parameter to achieve what you want in your case (see here).

    @BTStone Mhmm first of all you would still need a parent/child relationship, so you can move (or localMove) the parent and shake the child. Then, to start a continuous shake, you could use the new "continuous" shake option, which is not out yet. But let me get back to you with that, tomorrow or Friday max (including that delayed DOTween Pro single-axis option).

    @castor76 DOGradient only uses the colors of the gradient, but ignores the alphas, meaning they're always considered as 1. I realize that this information is written only in the intellisense popup and not on the website docs though, sorry. Updating it now.

    @adark Hi! Here's how that code looks in DOTween:
    Code (csharp):
    1. // HOTween
    2. seq.Append(HOTWeen.To(object.transform, 1.0f, new TweenParms().Prop("prop," value).Prop(etc)))
    3. // DOTween
    4. seq.Append(object.transform.DOMove(moveTo, 1)).Join(object.transform.DORotate(rotateTo, 1));
    5.  
    In short, you create a separate tween for each prop, and place them inside a Sequence. Join simply places the next tween at the same starting position as the previous one that was added, but there's also Insert and Append methods.

    @ortin Hi! You can set DOTween's LogBehaviour in the Utility Panel. If you set it to Verbose, you'll get more logs. Still, you'll get no logs for tweens that are killed because their target becomes null. I thought that, in that case, none was necessary? Let me know if you disagree.
     
    JakeTBear likes this.
  20. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Thanks for the reply.

    I will try to remove some dlls.

    As for the gradient, it's fine to just tween the color only. (if that is what is intended) but the problem is it is messing up the alpha value as well. To something really weird! like some crazy over the top 1 ? ( maybe like 1000?) not sure!
     
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @castor76 That is weird, alpha shouldn't be able to go beyond full alpha, and I don't touch it all, I just apply the color keys of the gradient :O Can you replicate it in a barebone project and attach it here, so I can check it out?
     
  22. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Thank you. But actually it is not what I need. First of all I need to rotate Vector or a Quaternion, not the transform. Because I need to tween multiple rotations, and then add them together in various ways, and base some other things of of them. I could use your beta Blendable variants, but it would be much easier for me if there would be a parameter that would allow me to treat Vectors as rotations. ANd I need the Fast(),

    I would even prefer not to have any shortcuts in the API, and to use only DOTween.Method syntax, it feels much cleaner then heaps of extencion methods, which feels like the entire API was invaded :)

    So I just expected to be able to tween Vector as rotation or have DOTween.Rotate(V3, V3), or to have Dotween.To().RotationMode(mode)
     
  23. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @illinar Ah I understand now! Sure you can use the generic way (but with a Quaternion property, not a Vector3), like this:
    Code (csharp):
    1. // Let's say you have a Quaternion property called myQ
    2. // This rotates it to 0,0,180 in 2 seconds
    3. DOTween.To(()=> myQ, x=> myQ = x, new Vector3(0, 0, 180), 2f);
    Did I get it correctly?
    If you're wondering why the lambdas, that's because we're talking of an unknown property (so no shortcuts, plus you don't want shortcuts) and it's the absolute best way to change something without using Reflection, which I don't want to use ever again in a tween engine :)
     
  24. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    @Izitmee Thank you very much for the reply, again. Yes this line works, but it's ChangeValues() does not. (I gave three code examples earlier) I reckon it's a bug.

    And can you please answer one important question. I saw you were saying before that there suppose to be no allocation if I recycle. So I wonder if I'm doing something wrong because my DOTween constantly allocates some garbage.

    So this single line allocates 56 bytes per frame:
    Code (CSharp):
    1. _localRotationTweener.ChangeValues(_localRotationAnimated, _localRotationRaw);
    And this line would allocate 272 bytes per frame, or 600 if recyclable is false:
    Code (CSharp):
    1. DOTween.To(() => _localRotationAnimated, x => _localRotationAnimated = x, _localRotationRaw, 0.15f);
    It animates Vector3 if that matters. And autokill didn't make any difference in those tests.


    Changing both values on a float Tweener allocates 40 bytes. Changing one value allocates 20.

    Running 100 tweeners with changing values in an empty scene cause 9ms garbage collection 400 frames in. (On my fairly old PC.)

    Running 100 new recyclable autokill tweeners causes 28kb allocation per frame and 12ms garbage collection every 200 frames.
     
    Last edited: May 26, 2016
  25. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @illinar Hey I dont know about why ChangeValues might allocate memory, but about your second inquiry, using anonymous functions will always create memory.
     
  26. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @illinar Tweens shouldn't constantly allocate garbage at all: a running tween should generate 0 allocations. Allocations may happen when you create a tween (especially if it's the first of its type, since plugins are single instances cached when activated—meaning that the very first time you run a Quaternion tween the QuaternionPlugin will be created).
    Also, allocations do happen with ChangeValue, and the actual reason is type casting, since the assignment must find the correct T tween for the given values and operate it.
    In general, allocations should be minimal, but what I say about recyclable tweens is that they avoid "useless" allocations, while some are necessary (a lot of thought went into that, and they're truly necessary, even if minimal).

    I see that you're using DOTween inside the Update method. I didn't mention that previously because I thought it was for testing purposes, but note that that will generate a tween every frame, which is not the intended usage. Am I missing something here?

    About your previous code question instead, I'm a little confused. I apologize, but could you explain me better? ChangeValues works correctly here.
     
  28. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    @Izitmee Yes, I figured that you meant that Tweens don't allocate when they are just running. But I need to change values every frame because I use tweens mostly for following other objects. I'm gonna need possibly up to 200-400 tweens for turrets that will be smoothly turning towards targets that will be constantly moving, and just a bunch of tweens for smooth camera follow and rotation. I assumed that many people need to use tweens this way, but may be not that many tweens.

    Unity engine developers made a great effort lately to let you do anything without garbage allocation. Now all the physics queries have NonAlloc variants, and even procedural mesh can now be created without garbage allocation. I sure wish there was an option to change values in DOTween without allocation, even if it would be less elegant, it would totally be worth it, if that is at all possible without big changes.

    I've uploaded a test scene with a script for Quaternion ChangeValues possible bug.
     

    Attached Files:

    Last edited: May 27, 2016
  29. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    I think I found a bug with DOTWEEN on Windows 10 WSA Builds (which only happens when building on Master Configuration and only on .NET (not on IL2CPP).

    If I have a running Looped Tween when I change from one scene to another, I got a crash. I have to manually kill this tween before changing the scene to avoid the crash. On any other build configuration or platform it works killing the tween automatically before changing the scene.
     
    Demigiant likes this.
  30. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @illinar Tried your project and I understand the issue now. You should indeed use just ChangeEndValue, like this:
    Code (csharp):
    1. // Note how I use the optional parameters of DOChangeEndValue
    2. // so as to set the current tween's value as the starting one
    3. // (also, no need to call Restart)
    4. _tweener.ChangeEndValue(_originalTransform.rotation.eulerAngles, 0.2f, true);
    I understand your issues with allocation, but I thought about ways to avoid it and casting really needs to be part of the changeEnd/Start values. Even Unity couldn't avoid creating allocations in a lot of their parts (like the new UI, or their own internal animations).
    That said, I really wouldn't recommend using tweens for stuff that updates every frame (I personally never do, and I think very few users might). The scope of a tween is to create an animation that can run by itself, without being changed, recreated or updated every frame except from its internal engine. For things that need to change every frame, inside an Update call, I always recommend using custom code, eventually via Unity's internal lerp/slerp methods to make things smoother.

    @Wagenheimer Thanks for the info! I'm afraid that's not a bug, just a compiler issue. If the problem is that tweens are not killed automatically, it means try-catch blocks are disabled with the configuration you mentioned (like in some iOS configurations), and thus safeMode won't work. I'm going to add this info to the website immediately.
     
  31. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    @Izitmee I see, SetEndValue with snapStartValue is definitely how I should have done it. I assumed it's a bug because I got away with just ChangeValues in all other cases, and only Quaternion doesn't want to get tweened if I change both values and restart it.

    Thank you. Yes, I will need to write my code for interpolation. But for now DOTween will be perfect for prototyping and early development.
     
  32. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW DOTWEEN UPDATE v1.1.300
    • NEW: Added RectTransform.DOPivot/X/Y shortcuts
    • NEW: Added optional fadeOut parameter to Shake tweens
    • NEW: Added static PlayForward/PlayBackwards overloads that accept a target or an ID
    • BUGFIX: Fixed decreasing uint tweens not working correctly
     
    FuguFirecracker likes this.
  33. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    @Izitmee Do you know what the cause of this problem is:

    Inside of a Coroutine, I try to fade an image in (or out) with
    Code (CSharp):
    1. yield return imageGameObject.GetComponent<Image>().DOFade(255, 2.5f).WaitForCompletion();
    but instead of a 2.5 second fade the image is displayed immediately while the yield waits 2.5 seconds without doing anything.

    I'm using version 1.1.135 (newest on Asset Store)
     
  34. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Hi,
    Thank you very much for this cool asset!

    I am using it for some UI transitions. Is there any way to access the start position of the tween without having to save it every time? I need to place the rectransform back to where it was at the end of the tween before hiding it.
    There is a target property but not a source/start property.
     
  35. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Does DoFade use the RGB 255 scale?
    Could have sworn it was 0 to 1.

    Code (CSharp):
    1. .DOFade(1, 2.5f)
     
  36. ericbegue

    ericbegue

    Joined:
    May 31, 2013
    Posts:
    1,353
    Hi,

    Is there a way to tell DOTween to update on FixedUpdate instead of on Update?

    That would be necessary to use DOTween to update kinematic objects, since the physic engine is updated on FixedUpdate.
     
  37. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    Oh god... that was the issue!
    Thank you for pointing this out!

    Maybe this should be in the documentation or did I miss that somewhere?
     
  38. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    @ericbegue I could use that feature as well, for animating values that are only used during FixedUpdate, it's a tiny win in performance for me though..
     
  39. ericbegue

    ericbegue

    Joined:
    May 31, 2013
    Posts:
    1,353
    Actually, since Rigidbody has its own extension methods (DOMove, DORotate, ... ). This could be completely transparent to the user; we would not have to specify when the tweening is updated.

    I've made the following test to figure out when the tweening is updated:

    Code (CSharp):
    1. using UnityEngine;
    2. using DG.Tweening;
    3.  
    4. public class DOTweenTest : MonoBehaviour
    5. {
    6.     void Start()
    7.     {
    8.         //this.transform.DOMove(Vector3.forward, 100.0f ).OnUpdate( DOTweenUpdate );
    9.         this.GetComponent<Rigidbody>().DOMove(Vector3.forward, 100.0f).OnUpdate(DOTweenUpdate);
    10.     }
    11.  
    12.     void DOTweenUpdate()
    13.     {
    14.         Debug.Log(string.Format("D t={0:00.000} dt={1:0.000}", Time.realtimeSinceStartup, Time.deltaTime));
    15.     }
    16.  
    17.     void Update ()
    18.     {
    19.         Debug.Log(string.Format("U t={0:00.000} dt={1:0.000}", Time.realtimeSinceStartup, Time.deltaTime));
    20.     }
    21.  
    22.     void FixedUpdate()
    23.     {
    24.         Debug.Log(string.Format("F t={0:00.000} dt={1:0.000}", Time.realtimeSinceStartup, Time.deltaTime));
    25.     }
    26.  
    27.     void LateUpdate()
    28.     {
    29.         Debug.Log(string.Format("L t={0:00.000} dt={1:0.000}", Time.realtimeSinceStartup, Time.deltaTime));
    30.     }
    31. }
    32.  

    Conclusion: both Transform and Rigidbody have their DOMove(...) updated on Update.

    It should be ok to have Transform on Update, but Rigidbody should definitely be updated on FixedUpdate.
     
    zyzyx likes this.
  40. ericbegue

    ericbegue

    Joined:
    May 31, 2013
    Posts:
    1,353
    I find the answer in the online documentation:
    http://dotween.demigiant.com/documentation.php
    In the section: Tweener and Sequence settings

    It can be done with SetUpdate( UpdateType.Fixed ).
     
  41. tawak3500

    tawak3500

    Joined:
    Oct 28, 2013
    Posts:
    77
  42. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    @tawak3500
    Hey ! Turn on your messaging options in your profile, so I can send you a message...
     
  43. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    transform.DOPath(waypoints, totalTravelTime)
    .SetLookAt(0.01f) // Orients to the path

    i want use local move .so i use :

    transform.DOLocalPath(localWaypoints, totalTravelTime)
    .SetLookAt(0.01f) // Orients to the path
    but i notice that's not work well..........can u help me........
     
  44. tawak3500

    tawak3500

    Joined:
    Oct 28, 2013
    Posts:
    77
    I turned on the messaging option.
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    00christian00 likes this.
  46. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    @woshihuo12 What happens? Can you tell me more? not orients to the path, while orients to else..
     
  47. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    Hi, unfortunately it doesn't help.
    I mean code like this
    Code (CSharp):
    1.  
    2. DOVirtual.DelayedCall(2, () => { throw new Exception("test delayed"); });
    3. transform.DOLocalMoveX(10, 0.1f).OnUpdate(() => { throw new Exception("test update"); }).OnComplete(() => { throw new Exception("test complete"); });
    4. DOTween.To(() => 1, value => { throw new Exception("test setter"); }, 1, 0.1f);
    5.  
     
  48. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @woshihuo12 Maybe your default target's orientation is incorrect? Try to insert it inside an empty gameObject and rotate it until you find the correct one, then restart the tween.

    @ortin OH wait, you mean you want to throw your own exceptions? Or that example is just for test and even regular ones don't appear? Let me know.
     
  49. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    Is there a EaseType graph?
     
  50. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    It's for test.
    Also I don't see how that test may differ from regular NRE, IndexOutOfRangeException or any other exception which can happen in code path executed :)

    edit: I suck. I've just looked at your code and there ARE logging on exceptions (for callbacks) in safe mode. It was just that it's made via LogWarning and I had warnings disabled in the Editor log. o_O

    Though exception is still ignored in "test setter" example. Which probably makes sense as you cannot distinguish "destroyed object" exception from "user code" exception and if you rely on safe mode you can get a lot of "destroyed object" ones ...
     
    Last edited: Jun 6, 2016