Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. 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
    @xcube Did you try with the new package I sent you via PM?
     
  2. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,418
    You are my friend.
     
  3. agstanescu

    agstanescu

    Joined:
    Jan 31, 2013
    Posts:
    13
    Hi,

    I am looking to implement a stop-motion like effect using DOTween.
    I have something that works but it has some small design issues and I want other people's opinion on this.
    Basically what I want is to tween the position of an object from 0 to 10 let's say, but actually set the position of the object every X milliseconds. I know there is a snapping feature in DOTween, but snapping to integer is too coarse for my needs.

    To achieve this effect, I am using the generic To(getter, setter...) method. The provided setter simply ignores values until time accumulates to X milliseconds and then it actually sets the value to the object. It resets the time counter and repeats.
    There is a small catch that the setter might not be called an exact number of times and the object might never be set to the end value (the last set value might be ignored). To fix this, in the custom setter I also store the last value the Tweener tried to set, and onComplete I set this value to the object.

    To aid writing this code I created a small helper class named StopMotion which handles the time counting. Normally the user provides a getter and setter for his object's property. What I do is provide these callbacks to a StopMotion object.
    StopMotion class has a Get, Set and Complete methods which are the callbacks that actually get registered to the Tweener. These in turn could call the user's callbacks when needed.
    I created my own helper method StopMotionTo() method which looks like this:

    I think the code below is a better explanation than the paragraph above :)
    Code (CSharp):
    1.     public static Tween StopMotionTo(DOGetter<Vector3> getter, DOSetter<Vector3> setter, DOSetter<Vector3> complete, Vector3 endValue, float duration, int motionFps)
    2.     {
    3.         StopMotion<Vector3> motion = new StopMotion<Vector3>(getter, setter, complete, motionFps);
    4.         Tween tween = DOTween.To(motion.Get, motion.Set, endValue, duration).OnComplete(motion.Complete);
    5.         return DOTween.Sequence().Append(tween);
    6.     }
    A typical usecase looks like this:
    Code (CSharp):
    1.         StopMotionTo(() => t.localPosition,
    2.                     (val) => t.localPosition = val,
    3.                     (val) => t.localPosition = val,
    4.                     endValue,
    5.                     duration,
    6.                     motionFps);
    motionFps is the effects visible framerate. If motionFps=2, then I will be updating the object's position every 500ms.

    As you see above, I am actually creating and returning a Sequence. This is to overcome the design problem that I found.
    The stop-motion object must have its Complete method called OnComplete() in order to set the endValue to the object. If the StopMotion.Complete must be called when the tween completes, it removes the possibility for the user to also register an OnComplete callback (as you can only have one callback registered in the tween).
    The sequence solution works as the user can register on the sequence's OnComplete() but it also limits the user's ability to further customize the tween (like set the ease type, make it a From tween, etc).

    One solution would be to allow for multiple OnComplete callbacks to be registered in a Tweener and in this case I would be able to simply return the Tween object instead of a Sequence.

    Another solution would be the Setter to also receive a float between 0 and 1 that could represent the tween percentage. This way, in the setter I could test if this percentage is 1 and always set the value. This would remove my need to use the OnComplete callback and free it for the user

    How would somebody else go about implementing this stop-motion feature?

    Thanks,

    PS: GG for the really hard work Daniele, I find DOTween to be the best tween library there is at the moment.
     
  4. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    TMPro would be great.

    I bought this asset today so learning as I go.

    I just wondered whether when using a DTPath in the inspector, if Local Movement / Relative are selected, whether the waypoints should be relative as well rather than absolute? Otherwise you have to move it to the origin to understand the span of the waypoints.

    I also wonder whether having Local and Relative as separate confuses things? as maybe they should be combined.

    As a possible suggesting it would be nice to have each waypoint selectable / movable by pressing W (unity standard) which would reveal the standard Unity Move Gizmo. This is the way Curvy handles paths. The extra benefit here would be that using things like SnazzyGrid would be easy.
     
  5. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    Hi

    With DTPro I am struggling to integrate DoTweenPath with objects/prefabs that live in a pooling solution and I was wondering if anyone had any advice.

    On my object I have added a DoTweenPath script that moves an object/prefab up or down - this tests fine in a simple scene when I set autoplay to true.

    However I then set autoplay to false when I put it in the pooling solution. I have add another script that tries to start and stop the animation when it is Spawned and Despawned respectively like this:

    voidOnSpawned () {
    transform.DOPlay();
    }

    void OnDespawned () {
    transform.DOKill();
    }

    However it never animates at all and I do not know what the problem is, so any help much appreciated. I have been able to manually add such features with normal DOTween using DoLocalMove() instead of DoPlay as above.

    Does anyone know how I can start stop the animation manually that has been set by a DoTweenPath in DTPro?

    thanks

    Nalin
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    DOTween Pro warning
    (good news and "ohno, changes!" news)


    After a hard day's work, I just implemented a way to have DOTween Pro's Visual Animation Editor work also with external plugins (for now 2D Toolkit and Text Mesh Pro). This is the good news, and I hope you will like it.

    The "ohno, changes!" news are that, in order to do so, I had to change some part of the architecture. None of your existing animations will be lost, but you'll have to manually reassign the DOTweenAnimation components. As soon as you do that, all your previous animation settings will reappear correctly. I apologize for this, but I guess it's worth it if it allows me to support external plugins.

    How to do upgrade:
    When you upgrade to DOTween Pro 0.9.100 (coming within a couple days to the Asset Store: the approval should be quick, but they need to approve two updates in a row now), you will get some "missing component" warnings in Unity's console. Drag & drop the DOTweenAnimation file (from the Demigiant > DOTweenPro project folder) to the Script field of each of those Components. Done.

    If you want to get your hands on the update as quick as possible, write me using the Support E-Mail link you'll find here, attaching the receipt of your DOTween Pro purchase. If I'm not at dinner or sleeping (Italy time here) I'll send it to you immediately.

    Ok, now to answer the previous questions in the next post (give me a short while though, that first I have to send the update to the Asset Store).
     
    Last edited: Apr 4, 2015
  7. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @agstanescu Mhmm that is indeed an interesting concept I never thought about. Let me experiment with it, and maybe I could even implement that as a DOTween feature (not promising anything). A coroutine approach might be another way, though it would create allocations every frame (because, you know, coroutines), even if so small they could be ignored. I might get my hands on it tomorrow but I'm not really sure, since today I killed myself to implement new DOTween Pro stuff and now I'm way behind with other things (not to mention that there's water dropping down from my bathroom's floor, so I'll have to deal with that too).
    P.S. thanks for the GG, glad you like it :)

    @puzzlekings Added all those stuff to my todo list, and will investigate a better usability for local+relative. TMPro is done. If you want it asap follow the instructions in the previous post :)

    About your spawning issue, the problem is that the tween is created inside a Start call, and I assume you're calling OnSpawned inside an awake, so there is still no tween to play and the call silently fails. I usually prefer to do things within OnStart calls for safety, but there's really no reason here. I'll move the call to Awake in the next update.
    Right now, what you could do is start a coroutine that waits one frame before starting the DOPlay:
    Code (csharp):
    1. IEnumerator OnSpawnedCoroutine() {
    2.    yield return null;
    3.    transform.DOPlay();
    4. }
     
  8. agstanescu

    agstanescu

    Joined:
    Jan 31, 2013
    Posts:
    13
    @lzitmee Thanks, and don't worry about the timing for something more permanent. For the moment I am running smoothly on this version I have. I discovered your github repo, forked and changed it a little - when registering a callback using OnComplete(TweenCallback) it adds it to the delegate (+=) instead of setting it (=). This way you can call .OnComplete on a tween multiple times and all the callbacks will be called in that order (thanks c#). I was really lazy and did it just for OnComplete.

    Regarding your desire to implement something like this permanently in DOTween, you could approach it from multiple angles. The solution I chose above also allowed me to easily add a jitter to the motion (adding a small random offset to the value), to give it a more life-like look, but maybe this is something very user-specific.

    Another idea I had today was using a custom ease method. One that could act as a proxy, and have an underlying standard ease function, but filter the values and return then in a steps-like pattern. This means the ease evaluation simply returns the same value for several frames until it jumps to the next step and results in a new value for the setted value

    Anyway, thanks again :)
     
  9. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    I tried this co-routine approach and while it works with a normal game object in the scene, I cannot get it to work with the Spawner as above. I even tried increasing the delay to 0.25 seconds but this fails as well.

    What happens is that the object appears momentarily, and then disappears. What seems to happen is that the object is spawned in the right position, but when the Tween starts playing it seems to ignore it's current position and move it elsewhere in the scene, despite the fact that the movement is set to local.

    Any other ideas would be welcome, if not I hope the forthcoming change fixes this :)

    cheers

    N
     
    Last edited: Apr 3, 2015
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @agstanescu The ease way is very clever and I like it a lot. Though I would be against it. Even in stop-motion behaviour it's nice to have an ease applied. I actually pondered more about this and thought how to add it. It would be definitely doable, but I'd need to add two float variables to each Tween, which would make them weigh additional 8B. Will think more about this. Fascinating argument :)

    @puzzlekings Oh wait, local movement means you will tween an object's localPosition instead than its position. If you want to move your object relative to its starting point, check the "relative" checkbox instead.
    dotween.png
     
  11. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    I did set relative (as per the image below), but it does not work when spawning - this is the key issue now.

    My DTObject Script which is attached is as follows:

    Code (CSharp):
    1. public class DTObject : Obstacle {
    2.  
    3.     void Awake()
    4.     {
    5.         OnSpawnedOrAwake();
    6.     }
    7.     void OnSpawned () {
    8.  
    9.         OnSpawnedOrAwake();
    10.     }
    11.  
    12.     void OnSpawnedOrAwake()
    13.     {
    14.         StartCoroutine(CR_StartTween());
    15.     }
    16.    
    17.     IEnumerator CR_StartTween() {
    18.  
    19.         yield return 0;
    20.         transform.DOPlay();
    21.     }
    22.  
    23.     void OnDespawned () {
    24.         transform.DOKill();
    25.         StopAllCoroutines();
    26.     }
    27.  
    28. }
    Any ideas?

    N


    Screen Shot 2015-04-03 at 11.15.40.png
     
  12. agstanescu

    agstanescu

    Joined:
    Jan 31, 2013
    Posts:
    13
    @Izitmee That is why I mentioned that it's kind of a wrapper ease, on top of a standard one (In, Out, Cubic, Quad, etc). When it comes evaluation time, this wrapper ease evaluates the inner standard ease, but it modifies the values to turn them into a step-like pattern.
    Regarding the implementation, I just saw there is the possibility to assign a custom ease function (from an AnimationCurve or just a EaseFunction delegate). I will try to create this stop-motion ease wrapper and come back with results. I think it should do the trick. Memory-wise, worst-case, you have a function reference for all tweens (instead of a null pointer).

    I attached an image of how I would see this wrapper ease behave for a normal curve.
     

    Attached Files:

    Last edited: Apr 3, 2015
  13. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @puzzlekings Oh I understand now, and sorry for getting confused between DTAnimation and DTPath in the previous answer. It's my fault then, because a path is "pre-scripted" to make it more efficient at runtime. I'm gonna work on this today and make the waypoints truly relative in case of spawning and then playing. Should be able to send you an update this evening (UTC+1), hopefully :)

    @agstanescu Whooops sorry missed the fact that you would actually wrap the ease into a stop-motion one. If you manage to do that, you are my god and it sounds awesome :)
     
  14. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    Thank you.

    However, when I use a DTPath instead of DTAnimation I get the same problem regarding animations not playing when spawned when I use the code above, so perhaps there is something else that needs to be changed as well?

    N
     
  15. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @puzzlekings Just sent you a PM that fixes the "relative" issue. Gonna investigate on the playing issue now (actually in a couple hours).
     
  16. agstanescu

    agstanescu

    Joined:
    Jan 31, 2013
    Posts:
    13
    @Izitmee I'm happy :)
    I found a solution that's quite elegant. Behold, the EaseFactory class. Its purpose is to generate custom EaseFunctions. You can use it with the .SetEase() method of a tween.

    Here is the class that has a demo StopMotion method:
    Code (CSharp):
    1. public class EaseFactory {
    2.  
    3.     public static EaseFunction StopMotion(int motionFps, EaseFunction innerEase = null) {
    4.         // Fallback
    5.         if (innerEase == null)
    6.             innerEase = StandardEaseFunction(DOTween.defaultEaseType);
    7.  
    8.         // Compute the time interval in which we must re-evaluate the value
    9.         float motionDelay = 1.0f / motionFps;
    10.  
    11.         return delegate(float time, float duration, float overshootOrAmplitude, float period) {
    12.             // Adjust the time so it's in steps
    13.             float steptime = time - (time % motionDelay);
    14.  
    15.             // Evaluate the ease value based on the new step time
    16.             return innerEase(steptime, duration, overshootOrAmplitude, period);
    17.         };
    18.     }
    19.  
    20.     // easeType must not be INTERNAL_Custom since we don't pass a customEase parameter
    21.     public static EaseFunction StandardEaseFunction(Ease easeType)
    22.     {
    23.         return delegate(float time, float duration, float overshootOrAmplitude, float period) {
    24.             return EaseManager.Evaluate(easeType, null, time, duration, overshootOrAmplitude, period);
    25.         };
    26.     }
    27.  
    28. }
    And this is how you would use this class (taken from the Basics example scene you had):

    Code (CSharp):
    1.         // Let's move the red cube TO 0,4,0 in 2 seconds
    2.         EaseFunction innerEase = EaseFactory.StandardEaseFunction(Ease.Linear);
    3.         EaseFunction easeFunc = EaseFactory.StopMotion(1, innerEase);
    4.         redCube.DOMove (new Vector3 (0, 12, 0), 10).SetEase(easeFunc);
    5.  
    6.         // Let's move the green cube FROM 0,4,0 in 2 seconds
    7.         greenCube.DOMove(new Vector3(0,4,0), 2).From().SetEase(EaseFactory.StopMotion(5));

    As you can see, the StopMotion method receives a motionFps and another EaseFunction (the innerEase). The way it generates the stop-motion effect is explained in the comments. I thought it's more generic to receive another EaseFunction as parameter instead of Ease types.
    To aid this, I created the StandardEaseFunction() which basically converts a Ease type into a EaseFunction.

    All this was done without changing anything in DOTween (Kudos).

    I then started thinking what if the library would operate only around EaseFunctions instead of EaseTypes. But then I researched a bit and discovered that a delegate member normally take 32 bytes of space (link). It's pretty heavy to have on all tweens.

    Considering how easy it was for me to add this behavior (which is something very user-specific, others might want it differently) I don't know if it's worth integrating this in the core library. It would only bloat it.

    You can also find this implementation on my github fork (Basics example scene): https://github.com/reydanro/dotween

    What are your thoughts?
     
    gjf likes this.
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @agstanescu That is very beautiful and smart and I love it! :) I played with it, and I would actually love to integrate it, if you allow me.

    To implement it with regular easings, I'll add a conversion method to EaseManager, so that it can return an EaseFunction from an EaseType, then modify EaseFactory so the API can accept both an EaseType, an EaseFunction, and an AnimationCurve. I will actually start on that now (but if for any reason you prefer me not to do this I'll obviously scrap it).

    P.S. yup bytes are the reason I'm using EaseType. HOTween stored EaseFunctions but this way it's much more lightweight.
     
  18. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @agstanescu Just so you know, I implemented it in the meantime and it's lovely. Waiting for your approval to commit :)

    API with overloads:
    Code (csharp):
    1. SetEase(EaseFactory.StopMotion(int fps));
    2. SetEase(EaseFactory.StopMotion(int fps, Ease ease));
    3. SetEase(EaseFactory.StopMotion(int fps, AnimationCurve animCurve));
    4. SetEase(EaseFactory.StopMotion(int fps, EaseFunction customEase));
     
  19. agstanescu

    agstanescu

    Joined:
    Jan 31, 2013
    Posts:
    13
    @Izitmee I'm glad you liked it and of course you can integrate it.
    I think the StopMotion method I wrote above need to be tweaked a little. I forgot the termination special case where you would want the object to still reach the endValue. It would look something like this.
    Code (CSharp):
    1.        return delegate(float time, float duration, float overshootOrAmplitude, float period) {
    2.             // Adjust the time so it's in steps
    3.             float steptime = time;
    4.             if (duration != time)
    5.                 steptime = time - (time % motionDelay);
    6.             // Evaluate the ease value based on the new step time
    7.             return innerEase(steptime, duration, overshootOrAmplitude, period);
    8.         };
     
  20. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Ran into a problem with a repeating sequence that I was able to reproduce in a simple project, and which I was going to attach, but I guess this forum doesn't allow it...? Anyway, it's simple enough -

    If you have a sequence set to repeat with the Restart type, it seems to skip the first Tweens in the sequence (edit:when it repeats.)
    This is supposed to consistently move a sprite to the same three points.
    Interestingly, if you uncomment the commented out AppendInterval in the project, it seems to work better.

    Code (CSharp):
    1. public class TestScript : MonoBehaviour
    2. {
    3.     public GameObject theSprite;
    4.  
    5.     // Use this for initialization
    6.     void Start ()
    7.     {
    8.         Sequence aSequence = DOTween.Sequence();
    9.         aSequence.SetLoops(-1, LoopType.Restart);
    10.  
    11.         //--
    12.         //aSequence.AppendInterval(1.0f);
    13.         aSequence.AppendCallback( ()=>MoveSpriteToPoint(new Vector3(0, 0, 0)) );
    14.         aSequence.AppendInterval(2.0f);
    15.         //--
    16.         aSequence.AppendCallback( ()=>MoveSpriteToPoint(new Vector3(2, 0, 0)) );
    17.         aSequence.AppendInterval(2.0f);
    18.         //--
    19.         aSequence.AppendCallback( ()=>MoveSpriteToPoint(new Vector3(4, 0, 0)) );
    20.         aSequence.AppendInterval(2.0f);
    21.          //--
    22.  
    23.         aSequence.Play();
    24.     }
    25.  
    26.  
    27.     void MoveSpriteToPoint(Vector3 destPos)
    28.     {
    29.         Tweener aTween = DOTween.To(()=> theSprite.transform.position,
    30.                                     x => theSprite.transform.position = x,
    31.                                     destPos,  0.5f);
    32.         aTween.Play();
    33.      
    34.     }
    35.  
    36. }
    37.  
    Now, off to buy DOTweenPro!
     
    Last edited: Apr 4, 2015
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @agstanescu Added the termination special case and committed (as an additional EaseFactory class inside DOTween's root)! :) I'm attaching a compiled ZIP. Let me know what you think, and I'll release it officially later.
    I also added you to DOTween's credits, let me know if you prefer to use a different link.

    @djfrail Agh! I can't test it now, but will do that later or tomorrow! If you get DOTween Pro (thanks for that!), write me a mail using the instructions here, so I can send you the latest version before you start using it (Asset Store is way behind with the updates —probably they're going slower because it's Easter) :)
     

    Attached Files:

  22. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239

    Attached Files:

  23. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    348
    Is there an easy way to precache tweens? I seem to get hiccups when I use tweens for the first time (on Android, BTW), but over the time performance gets better - so I guess the reason is the pool gets filled tween by tween only. Would be cool to fill the pool with tweens from the beginning, I guess?
     
  24. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @ratking Adding that to my todo list. Though I believe those hiccups might be more related to Unity's rendering and warming period, other than tweens.
     
  25. myak

    myak

    Joined:
    Mar 30, 2015
    Posts:
    5
    @Izitmee any chance for InOutSwing (and InSwing, OutSwing) ease types? They're implemented in libgdx, the source is here. I had a (very) quick look on how are eases implemented in EaseManager to see if maybe it's named differently in DOTween (or if maybe I could do it myself), but didn't find it.
     
  26. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @myak Could you post me a link to how the swing tween works, or an explanation of its behaviour? That way, I could understand what it does and try to implement it myself (or ask libgdx's Nathan Sweet if I can use his own equations).
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @myak P.S. at least from here, it looks like an Ease.In/Out/InOutSine, but maybe jQuery's implementation is different?
     
  28. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    UPDATE 1.0.445
    • NEW: DOScale shortcut now can also accept a float instead of a Vector3, to scale stuff uniformly
    • NEW: Added DOTween.Play/Restart(target, id) overload, to play/restart a tween only if both the given target and the given id correspond
    • NEW: Implemented EaseFactory.StopMotion by Andrei Stanescu
    • BUGFIX: Fixed DORewind/DORestart shorctuts working on all tweens instead than only on the ones started from the target
    • BUGFIX: Fixed Sequence Callbacks at 0 time not being fired after the first loop cycle (if using LoopType.Restart)

    Also, in case you might need it, I wrote an HOTween to DOTween upgrade guide :)
     
  29. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    just bought the Pro. For the Do Tween Animation i suggest to add. OnEnable play animation for example.
    I use the plugin since the beta. I got an grid movement working and now i working on simple effects for my quarths game.
     
  30. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @meapps Thanks for buying it! :) And that's a very interesting and righteous suggestion. Gonna find a smart way to implement it now (and OnDisable too) and then push the new Pro release (which implements many new features, both for controlling the tweens and for other stuff like Punch and Shake animations).
     
  31. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    Hi @Izitmee

    I just wanted to publicly say a big thanks for all your help recently in getting DOTweenPro to work with a pooling solution. This is awesome support you provided and I have a hard time keeping up with all your updates !

    Just trying to look through and it seems TMPro extensions have made it through - do you have any examples of its use?

    cheers

    Nalin
     
  32. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey @puzzlekings!

    You will be even more happy with a new update I'm working on :) It will allow to choose per-gameObject DOTweenAnimation/Path behaviour when it's enabled or disabled, meaning you will be able to Rewind/Restart without additional code, when using a pooling solution like yours.

    Gonna add TMPro docs tomorrow. In the meantime, you can simply start a DO from a TMPro reference, and IntelliSense will show you all available methods. In short, they're:
    • DOColor
    • DOFaceColor
    • DOOutlineColor
    • DOGlowColor
    • DOFade
    • DOFaceFade
    • DOScale (to scale uniformly using a float instead than a Vector3)
    • DOFontSize
    • DOMaxVisibleCharacters
    • DOText
    Cheers!
     
  33. woondal

    woondal

    Joined:
    Feb 23, 2014
    Posts:
    10
    Code (CSharp):
    1.  
    2. Sequence sq;
    3.     void Awake()
    4.     {
    5.         sq = DOTween.Sequence();
    6.         sq.Append( transform.DOScale( new Vector3( 0.5f, 0.5f, 0.5f ), ScaleDuration ).From().SetEase( ScaleEase ) );
    7.         sq.Join( transform.DOLocalMoveX( MoveDistance, MoveDuration ).From().SetEase( Ease.OutBack ) );
    8.         sq.AppendInterval( ShowDuration );
    9.         sq.Append( transform.DOLocalMoveX( -MoveDistance, MoveDuration ).SetEase( Ease.InBack ) );
    10.         sq.OnComplete( OnComplete );
    11.         sq.SetRecyclable( true );
    12.     }
    13.     public void Tween()
    14.     {
    15.         sq.Restart();
    16.     }
    17.  
    Seems that Restart() or Rewind() doesn't work on Sequences. It works fine first time when I call Tween() but but it doesn't work from the second time.

    Or am I doing something wrong?
     
  34. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @StrawberryDaddy Your Sequence (as any other tween) will be auto-killed when it's complete, to improve memory usage. If you want to reuse it more than once, you have to add a SetAutoKill(false) to it :)
    Code (csharp):
    1. // ...
    2. sq.OnComplete( OnComplete );
    3. sq.SetRecyclable( true );
    4. sq.SetAutoKill(false);
    5. // ...
     
  35. myak

    myak

    Joined:
    Mar 30, 2015
    Posts:
    5
    @Izitmee I think jQuery's implementation of Swing is different. I put the libgdx equations in WolframAlpha (SwingIn, SwingOut) and they look exactly like jQuery's easeInBack, easeOutBack. These are already in DOTween as far as I can see, so I guess it's problem solved. Thanks!
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @myak Great! And glad to see WolframAlpha being used, I always forget about it :)
     
  37. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @Izitmee great update. Finally i know how to use sequence ^^
     
    Demigiant likes this.
  38. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    Possibly silly question, but do I need to keep updating both my DOTween AND DOTweenPro now that I own Pro, or can I just worry about updating Pro? The Asset store is showing an update to DOTween for me currently....
     
  39. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    In other news, I've got a fun one for you: I'm hoping you've got an iOS device to test on, as iOS builds crash if the Tween is not explicitly killed in the GameObjects OnDisable. PC builds work fine :(
    For example, ioscrash.JPG

    these settings crash iOS when I change scenes, but it works fine on PC. If I manually create that using a sequence, keep a reference to it, and put the following code:
    void OnDisable()
    {
    DOTween.Kill(hitSequence.id);
    }
    then both builds work fine, but I don't get the convenience of using the DO Tween Animation script!

    This also happens when I do DOTween.Init in SafeMode.

    Screen Shot 2015-04-08 at 4.17.07 PM.png
     
    Last edited: Apr 8, 2015
  40. woondal

    woondal

    Joined:
    Feb 23, 2014
    Posts:
    10
    @Izitmee That worked! Thank you :)
    I have one more question. The sequence automatically starts on Awake() of my code.

    Here is the log.
    ScreenClip [1].png

    The sequence played automatically and called the callback function 'OnComplete'.

    Do I have to manually pause a sequence after setting it up?
     
  41. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @timothyallan I would recomment just installing DOTween Pro from the Asset Store, and eventually checking if a new DOTween update came out now and then with DOTween Utility Panel's "Check Updates" button (because the Asset Store is superslow to push updates).

    About your iOS error, safe mode doesn't work correctly on iOS unless you follow these instructions (because otherwise iOS deletes try-catch wrappers from your build, preventing all error management).
    Otherwise, you could set your gameObject to kill a tween when it's deactivated, by using the new DOTweenVisualManager component that you can add by pressing "Add Manager" from a DOTweenPath/Animation (gonna PM this update to you now) :)
    dotweenvisualmanager.png

    @StrawberryDaddy To prevent a Sequence from starting automatically, you can either Pause it immediately after creation, or you can set the AutoPlay behaviour in "Tools > DOTween Utiltity Panel" to "Auto Play Tweeners" instead than "All", which will activate autoplay only on Tweeners and not on Sequences.
     
  42. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Ok, since the Asset Store is sooo sloooow, I created a forum with a private download area to manage faster releases :) So...

    To access the latest version of DOTween Pro as fast as possible, follow these instructions.
     
  43. Andres_T

    Andres_T

    Joined:
    May 6, 2014
    Posts:
    2
    Hi! I've been happily using both DOTween and TMPro for a while now, but hadn't managed to do proper text fading until now, so I haven't thought twice before buying DOTween Pro as soon as I've seen it was TMPro shortcuts!
    I'm struggling to get them to work, though. I've created a new project, in Unity 5.0.0f4, installed the latest DOTween Pro version in the Asset Store (the tool says DOTween v1.0.425 and DOTween Pro v0.9.020) and TMPro 0.1.5 Beta 1.3.1. I've then created a Textmesh Pro object and a new script with a reference to it. But I get an error when trying to use the DOFade shortcut on the TMPro object:
    error CS1928: Type `fader.textTest' does not contain a member `DOFade' and the best extension method overload `DG.Tweening.ShortcutExtensions.DOFade(this UnityEngine.SpriteRenderer, float, float)' has some invalid arguments

    Am I missing something? Is it a compatibility issue with Unity 5, by any chance? (the Asset Store says that DOTween Pro may not be compatible with Unity 5, hence my question).
     
  44. Demigiant

    Demigiant

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

    the Asset Store version is way behind (they're still approving the last submission, which sadly may take even a week, or more). I setup a private forum to let users download the latest version, which will work perfectly with TextMesh Pro :)

    Follow these instructions so I can give you access

    P.S. and thanks for buying DOTween Pro! :)
     
  45. Crazydadz

    Crazydadz

    Joined:
    Mar 29, 2012
    Posts:
    50
    Hi! First of all, nice job! I've been trying HOTween before, and DOTween is a lot better!

    I have some questions:

    1. I bought DOTween Pro to help you and also for TextMesh Pro shortcuts. Do we have access to the source code to add some features? At the moment, I'm animating the FaceDilate and Underlay material property of TextMesh Pro with my custom poor tween system. It will be nice to have shortcuts to animate them. I could use the generic way (didn't test it yet with material property).

    2. Is there a way to have a tweener/sequence with infinite loop and complete the tweener/sequence with a trigger or something.
    Ex:
    New Sequence
    ---->fadeIn
    --->infinite loop tweener/sequence
    ---->wait for an event to step forward in sequence
    --->fadeOut

    What I have done with my custom poor tween system is a tween that will play until it reachs the end (if non-infinite) or until an event occur (I'm passing a boolean with a delegate and the tween is keeping track of this boolean. If the boolean is true, the animation is completed). Not sure if I totally lost you with my poor english.

    Thanks a lot!
    David
     
    Last edited: Apr 9, 2015
  46. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Crazydadz Hi David! And thank you for buying DOTween Pro :)

    1. The source code for TextMeshPro shortcuts is actually lose script (because otherwise I wouldn't be able to communicate with other lose scripts). You can find it "Demigiant/DOTweenPro/DOTweenTextMeshPro.cs" if you want to add more shortcuts. That said, I wrote those properties in my todo list, and will add them in the next release (in a couple days more or less, because now I'm going to bed and tomorrow I'll travel all day).

    2. Infinite looping tweens can't be completed. But you could use a trick, and just insert the highest possible value for loops (Int32.MaxValue), so it will be practically infinite, and then Complete will work.

    Cheers!
    Daniele

    P.S. remember to follow these instruction if you want to get the latest DOTween Pro release as soon as possible (even if right now the Asset Store version is the last one).
     
    Crazydadz likes this.
  47. Andres_T

    Andres_T

    Joined:
    May 6, 2014
    Posts:
    2
    Understood, I've already requested access to the forum to get the last update.
    Thanks to for all your great work on DOTween! :)
     
  48. Crazydadz

    Crazydadz

    Joined:
    Mar 29, 2012
    Posts:
    50
    Thank you for your quick response.

    Will be fun to have a way to use "non hack" infinite inside sequence or tween with a complete trigger :)
     
  49. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    Not that slow as it's out on the asset store now ;)
     
  50. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Yup, that was surprisingly fast! I wrote a "please please approve this quickly" message when submitting, and they took it kindly and did it quickly. Though I'm afraid it might be an exception, because the free DOTween asset is instead still unapproved. We'll see ;)