Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

DOTween (HOTween v2), a Unity tween engine

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

  1. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Glad you like it. If you wait a couple hours I'll work on it now and release an update with DOShakePosition/Rotation for transforms ;)
     
  2. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
  3. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    759
    I'm using HOTween for a lot in my current project and I just took the time to look a bit closer at the docs for the new version. I'm pretty excited about the revamped way of doing tweens. I thought HOTween was much better than iTweens hash values but always found the tween parameters and properties slightly less than straightforward. I'll never really utilized lambda expressions before but even so this is looking much better. Less lines of code is always good!!! Of course performance increases look promising as well.

    Anyway basically just wanted to say that I truly appreciate your work. I've used your tweening engine in every game I've released and find it indespensible. I will certainly buy the Pro version of DOTween when it is released! Keep up the awesome work

    EDIT:
    Will there be a new visual editor? If so will it have any usability enhancements? I thought the HOTween visual editor was hard to use for tweens you wanted to trigger sometime after start
     
  4. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Glad you're liking it and thanks for the appreciation! About lambda, I love them since a long time and I recommend getting to know them well not only for DOTween purposes :)

    I'm not planning a Visual Editor for now (because that's another thing I spent tons of time supporting but never used myself), but @Dávid Debnár might pull one out of his hat.
     
  5. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    759
    Yes I really do need to get my act together with the whole lambda thing (this is what happens when you learn programming using Java). Totally understandable about the visual editor. I imagine it's hard to make a visual interface to such a flexible system. At the end of the day it's not really needed as it's not hard to build some editor tweaking into individual components for specific needs anyway.
     
  6. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Sneak peek of a special plugin + shortcut I just created for the future Pro version: Spiral tween.

    Code (csharp):
    1. transform.DOSpiral(duration, direction, spiralMode, speed, frequency, depth, snapping);

    The spiral can be made to expand for the whole tween or to expand then contract. You can also move the object along the spiral's axis, choose the rotation axis, speed, spread and eventual pixel-perfect snapping. It also works with LoopType.Incremental for infinite spirals :)
     
    Last edited: Aug 28, 2014
    TheValar likes this.
  7. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Hi dude, I was recently doing some combinations with Script coding and Artist work, currently when I click Play in my game Unity3d crashes and if I leave it without manually closing getting this issues.

    Code (CSharp):
    1. DOTWEEN :: Max number of Tweens has been reached, capacity is now being automatically increased. Use DOTween.SetTweensCapacity to set it manually at startup
    2. UnityEngine.Debug:LogWarning(Object)
    And Red Warning:

    Code (CSharp):
    1. OutOfMemoryException: Out of memory
    2. System.Array.Resize[Tween] (DG.Tweening.Tween[]& array, Int32 length, Int32 newSize) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1928)
    3. System.Array.Resize[Tween] (DG.Tweening.Tween[]& array, Int32 newSize) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1912)
    4. DG.Tweening.Core.TweenManager.IncreaseCapacities (CapacityIncreaseMode increaseMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:660)
    5. DG.Tweening.Core.TweenManager.GetTweener[Vector3,Vector3,VectorOptions] () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:99)
    6. DG.Tweening.DOTween.ApplyTo[Vector3,Vector3,VectorOptions] (DG.Tweening.Core.DOGetter`1 getter, DG.Tweening.Core.DOSetter`1 setter, Vector3 endValue, Single duration, Boolean isFrom) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:702)
    7. DG.Tweening.DOTween.To (DG.Tweening.Core.DOGetter`1 getter, DG.Tweening.Core.DOSetter`1 setter, Vector3 endValue, Single duration) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:323)
    8. DG.Tweening.ShortcutExtensions.DOMove (UnityEngine.Transform target, Vector3 endValue, Single duration) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/ShortcutExtensions.cs:25)
    9. NewPlayer.WaypointComplete () (at Assets/_Scripts/NewPlayer.cs:117)
    10. DG.Tweening.Tween.DoGoto (DG.Tweening.Tween t, Single toPosition, Int32 toCompletedLoops, UpdateMode updateMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Tween.cs:212)
    11. DG.Tweening.Core.TweenManager.Update (Single deltaTime, Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:187)
    12. DG.Tweening.DOTween.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:101)
    13.  
    Any ideas?
     
  8. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    New Update 0.8.010

    - Added OnPlay and OnRewind callback
    - New architecture for custom plugins

    @MrEsquire Heya! That is a weird out of memory message, and I can't track it because you're using an old DOTween version. Can you download this latest one, try again, and if it still fails write me once more both the warning message (which is simply DOTween telling you it's automatically increasing the tweens capacity, but I added more informations to aid me in catching this bug) and the error log?
     
    Last edited: Aug 29, 2014
  9. FamerJoe

    FamerJoe

    Joined:
    Dec 21, 2013
    Posts:
    193
    Is there a way to tween two things at once in a sequence?

    something like:

    sequence.Append(transform.DORotate(rotateVector, 1),transform.DOScale(scaleVector, 1));
    sequence.Append(transform.DOMove(moveVector, 1));

    So the object would rotate and scale at the same time over 1 second, then move over one second.

    Thanks!
     
  10. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @FamerJoe Hi, sure you can. Other than Append, Sequences allow for an Insert method too, so you can achieve what you wrote like this:
    Code (csharp):
    1. sequence.Append(transform.DORotate(rotateVector, 1));
    2. sequence.Insert(0, transform.DOScale(scaleVector, 1));
    3. sequence.Append(transform.DOMove(moveVector, 1));
    Let me post the same thing but with chaining, just because I like it ;)
    Code (csharp):
    1. sequence
    2.    .Append(transform.DORotate(rotateVector, 1))
    3.    .Insert(0, transform.DOScale(scaleVector, 1))
    4.    .Append(transform.DOMove(moveVector, 1));
     
    FamerJoe likes this.
  11. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.035
    • CHANGE: Punch/Shake vibrato parameter is now an int
    • BUGFIX: Fixed Punch/Shake not working with some vibrato values
    • BUGFIX: Fixed Reset and SetAs not implementing the latest additions
     
    Last edited: Sep 2, 2014
  12. FamerJoe

    FamerJoe

    Joined:
    Dec 21, 2013
    Posts:
    193
    Fantastic, I didn't realize that was the functionality of Insert. Thanks!
     
  13. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    You're not the first one that doesn't realize it. I'll try to add some notes on the website to explain it better :)
     
    FamerJoe likes this.
  14. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.100
    • NEW: Introduced TweenParms object, just as an extra utility class you can use to store settings for multiple tweens
    • NEW: Added camera.DOColor, light.DOColor and light.DOIntensity shortcuts
    • CHANGE: Rotation tweens (DORotate) now take the shortest route to reach the given rotation and don't rotate more than 360° unless you choose otherwise (see the new optional useShortest360Route parameter in the various DORotate methods)
    P.S. I also changed the Sequence documentation hoping to explain better that tweens can overlap
     
    Last edited: Sep 2, 2014
  15. Trideka

    Trideka

    Joined:
    Mar 24, 2013
    Posts:
    16
    Hiya,

    Firstly great job. Easily the best structured and most well thought out tweening engine I've used so far.

    I'm having a peculiar issue though.

    I have a scene that I'm reloading if the player chooses to restart a level.

    However after reloading the scene, tweens no longer work.

    I have safe mode on. Thinking it might be issue there somehow.

    Note that they do work in the editor. This happens on builds for Android. I've not tried other platforms.

    On another note, using an animation curve in conjunction with ToAlpha results in errors to the console I can't make much sense of.

    Just a couple of issues. Thanks for your hard work. You're doing a fantastic job.

    -- edit

    Ah, maybe I'm an idiot here. Calling DOTween.Clear(true) in my scene reload method solves the issue.
     
    Last edited: Sep 3, 2014
  16. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @Trideka Glad you like it and thanks for the nice words :)

    While I certainly recommend calling DOTween.Kill to kill all tweens when a scene is unloaded (Clear works too, but it's like using an atomic bomb when a simple peace flag would suffice), that issue shouldn't happen if safe mode is on. I'll investigate it. In the meantime, can I ask you to try and see if DOTween.Kill solves the issue, or you truly need DOTween.Clear(true)?

    About ToAlpha and animation curves that's weird. Gonna investigate that too.
     
  17. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.110

    - NEW: DOTween Inspector now shows additional info
    - NEW: Incremental LoopType now works with every tween plugin, arrays included
    - BUGFIX: Fixed bug with string plugins not working with some animation curves

    @Trideka About ToAlpha, everything works perfectly here even with weird animation curves. Though I found a bug instead where animation curves caused errors with String tweens (solved in this update). Are you sure you didn't mistook it the error log? Otherwise, could you:
    • download this last version (so all lines of code are the same)
    • post the ToAlpha code you're using
    • run your project with this latest version and post the full error log (so I can see the line that's causing issues)
    • possibly post a screenshot of your animation curve
    About the Android issue, could you post the full error log here too (always with this latest version), so I can try to capture it?
     
  18. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Thank you for feedback, there was a code issue on our side, we rewrote this code and fixed.
    One new issue discovered as a result of this, issue present in Xcode when running app.
    Of course using latest version of DOTween.

    Code (CSharp):
    1. NullReferenceException
    2.   at UnityEngine.Transform.set_position (Vector3 value) [0x00000] in <filename unknown>:0
    3.   at DG.Tweening.ShortcutExtensions+<>c__DisplayClass2.<DOMove>b__1 (Vector3 x) [0x00000] in <filename unknown>:0
    4.   at DG.Tweening.Core.TweenerCore`3[UnityEngine.Vector3,UnityEngine.Vector3,DG.Tweening.Plugins.Core.DefaultPlugins.Options.VectorOptions].ApplyTween (Single prevPosition, Int32 prevCompletedLoops, Int32 newCompletedSteps, Boolean useInversePosition, UpdateMode updateMode) [0x00000] in <filename unknown>:0
    5.   at DG.Tweening.Tween.DoGoto (DG.Tweening.Tween t, Single toPosition, Int32 toCompletedLoops, UpdateMode updateMode) [0x00000] in <filename unknown>:0
    6.   at DG.Tweening.Core.TweenManager.Update (Single deltaTime, Single independentTime) [0x00000] in <filename unknown>:0
    7.   at DG.Tweening.DOTween.Update () [0x00000] in <filename unknown>:0
    8. (Filename:  Line: -1)
    Any ideas?
     
  19. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    This one should be related to your transform having been destroyed while the tween was still active. To solve it you can either kill the relative tween before destroying the transform, or you can activate safe mode which will take care of that automatically.

    EDIT: thinking of that, I will probably activate the safe mode by default in future updates
     
  20. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Hey, we are using safe mode and the transform never gets destroyed.
    I think this is some bug you have not come across yet, anything else I should check?
     
  21. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.130
    • NEW: Added DOTween43 DLL which contains shortcuts available only with Unity 4.3 or later. If you're using older Unity versions just delete the Unity 4.3 files
    • NEW: Added spriteRenderer.DOColor/DOFade (Unity 4.3 or later)
    • BUGFIX: Fixed safe mode not catching all exceptions
    IMPORTANT
    From this version on DOTween includes some shortcuts that are specific to Unity 4.3 or later. If you're on older versions, simply delete the "DOTween43" files in the DOTween folder after unzipping it: it's that simple :)

    @MrEsquire Answered in our private messaging. This update should fix it
     
  22. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    I started using Dotween today and already love it! It will be really nice if you could add the Unity 4.3 compatibility for the timescale thing. In a big project that takes a year+, you can't easily update unity version due to many code being broken upon update.
     
  23. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @noanoa Glad you like it, and I already made DOTween compatible with Unity 3.5 since a while. In the last update I started adding shortcuts that require Unity 4.3 or later (like spriteRenderer.DOColor/DOFade), but I kept them in a different DLL called DOTween43, so if someone is on older Unity versions they can simply delete the DOTween43 files. I will go on like that, so compatibility will always require just Unity 3.5 :)
     
  24. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Oh, I meant the behaviour when Time.timeScale is set to 0. Everything else worked great.
    I was trying something like this:
    transform.DOScale(new Vector3(1f,1f, 1f), 1f).SetUpdate(UpdateType.Independent);
    but it didn't tween when timescale was 0. Am I doing something wrong? o.o
     
  25. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Ooops sorry I misread your post then. I just checked (both with Unity 3.5 and Unity 4.5), and the Independent update type works even when timeScale is set to 0. Unless you're talking about DOTween.timeScale? Independent update is independent from Unity's timeScale, but not from DOTween.timeScale.
    If you were indeed talking about Time.timeScale, can you post a sample project that replicates the issue, so I can check if there's something else going wrong (the tween code you posted seems perfect - unless your object's scale is already 1,1,1)?
     
  26. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    I was trying to make a short sample project then found out that I wasn't putting SetUpdate on another tween object....How embarrassing mistake(sigh) sorry for taking your time and thanks for the replies. Now Dotween is indeed working perfectly.
     
  27. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Glad to know that the evil gnome of bugs didn't touch the independent update system :)
     
    noanoa likes this.
  28. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    @Izitmee Really loving all the support and updates, really impressed with how fast this is moving and looking forward to the pro version as the features in the normal version are already superseding many other variants.

    I think I may have found an issue related to the DoLocalAxisRotate and DoLocalAxisRotateFrom shortcuts as they now seem to throw an NullReferenceException and I think it might have something to do with the implementation of the useShortest360Route. Its possible I may have missed something I am supposed to enable, but if I have I cant see it?

    For the meantime I have reverted to DOTween v0.8.035 which doesn't throw an exception for me when using the shortcut, also adding to my suspicion it may be related to the useShortest360Route implementation as it's the version before it's included.

    Also, and this may well seem silly to mention, but I am experiencing some strange issues where some Tweens randomly repeat themselves and I cant quite put my finger on it. I was assuming it might be something to do with me (quite possible still) but it appears to be happening with different methods of calling the tween. For instance, some tween functions are being called by unity 4.6's new ui buttons, others are being called within coroutines and some are in standard functions, however, they all appear to do it occasionally, but without a consistent pattern as to why... What makes it even stranger is that almost all of them have onComplete functions attached which don't get called, so it is like it gets stuck somehow. Anyway, like I said this may well not be anything to do with DoTween (and also there are many variables involved in my implementation which I know isn't very useful for bug testing - sorry), but I thought I would mention it incase anyone else has experienced something similar???
     
  29. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.145
    • BUGFIX: Fixed DOLocalAxisRotate not working since the rotation logic was changed
    • BUGFIX: Fixed safe mode not catching all exceptions
    @RichHurst Hey Rich! This last update fixes the DOLocalAxisRotate/From issue (thanks for pointing me towards the useShortest360Route solution). About your other issue, I can't replicate it and never encountered it. If you manage to strip down a sample project that replicates it please throw it at me so I can check it out.
     
  30. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    Hey, thats great thanks...

    Yeah, I'll try to put something together but it might take some time as the issue is so sporadic in the first place and may well be down to something I'm doing. I knew it might sound silly, but thought it was worth mentioning on the off chance you had come across it or something similar...
     
  31. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Mentioning things is never silly ;)
     
  32. FuzzyBalls

    FuzzyBalls

    Joined:
    Jun 12, 2014
    Posts:
    47
    OnComplete is just a delegate right? Can I add parameters to it some how? line OnComplete (MyFunction (GameObject object)) etc?
     
  33. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    I am actually undecided about adding that option, because it would require allowing the storage of 2 different versions of each callback (one with parameters and one without), which would add a few bytes to each Tween instance. Right now, you can already access parameters instead by simply using a lambda this way:
    Code (csharp):
    1.  
    2. myTween.OnComplete(()=> {
    3.   // Access variables in your closure or stuff like that
    4. });
    5.  
    What you think of it?
     
  34. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    @Izitmee When could we expect shortcuts for new uGUI components? ;)
     
  35. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    As soon as they're out of beta (maybe sooner, but I'm concentrating on the rest of the core first) ;)
     
  36. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,520
    Hi there,
    Could you please make the Pro edition available for preorders ?
    E.g. people like me who have faith in your work can give you the amount of money you define ( preferably via Asset Store ) and you provide us the Pro edition when it is out ?
    Also, where are the example scenes ?
     
  37. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Hey @Ippokratis, thanks a lot for the vote of confidence :) Though the Asset Store doesn't accept preorders, and there is no way to grant something on the Asset Store unless it's bought directly from there. Also, I prefer to take money only when I have the Pro ready in exchange. That said, I'm almost finished implementing the Pro path plugin, so it should be ready for the end of next week (minus the Asset Store upload part, so probably in a couple weeks).

    About the example scenes, I'm waiting to have the basic version complete (actually it is already complete, but I want to finish implementing it in my mega-tween-based game — Goscurry — to be sure I'm not missing anything) and enter beta before making the examples, so I'll be sure no API will change (even if it's almost surely the final API already). I'll try to upload them within this week.
     
  38. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    I second @Ippokratis.
     
  39. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,520
    Great, thanks for the answer. I am ready to buy :)
    A suggestion : Give as a scrub option, i.e a slider that lets us scrub (move from the beginning to the end of the tween and vice versa) in editor and in game. This would be very useful for simulations - interactive applications. Imagine a 3d animation implemented from many tweens, all of them controlled by a master tween. By being able to control the master tween progression, you could move forward - backward the animation and change the camera parameters... Mind blowing stuff :)
     
  40. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @OnePxl I'll have to think about a way then, since you're now two ;)

    @Ippokratis I love scrubbers and that's actually one of the examples I want to make, since a scrubber like that can already be done by giving the same ID to the tweens you want to scrub, and then using DOTween.Goto filtered by that specific ID :)
     
  41. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    Hi, when i using

    Code (CSharp):
    1.  
    2.     public GameObject a, b, c;    // Sprite
    3.     public Sequence seqMain, seqA, seqB;
    4.  
    5.     void Start () {
    6.         seqMain = DOTween.Sequence ( );
    7.         seqA = DOTween.Sequence ( );
    8.         seqB = DOTween.Sequence ( );
    9.  
    10.         seqA.Append ( a.transform.DOMove ( new Vector3 ( ), 10f ) );
    11.         seqA.Append ( a.transform.DOScale ( new Vector3 ( 3, 3, 3 ), 10f ) );
    12.  
    13.         seqB.Append ( c.transform.DOMove ( new Vector3 ( ), 5f ) );
    14.         seqB.AppendCallback ( fin );
    15.  
    16.         seqMain.Append ( seqA );
    17.         seqMain.Insert ( 0, seqB );
    18.     }
    19.  
    20.     void fin( ) {
    21.         seqMain.Complete ( );
    22.     }
    I got the animation result finished (Moved and scale) but ArgumentOutOfRangeException throw. Should i leave it like that or any workaround?
     
  42. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    That looks like a bug. I'm running out now, but I'll check it out when I'm back (or tomorrow if I'm superlate).
     
  43. Reekdeb

    Reekdeb

    Joined:
    Nov 26, 2012
    Posts:
    6
    I am stuck at changing material colors different from the default one. How do I animate "_TintColor" property?
    Is it possible to do in generic way using lambdas?
     
    Last edited: Sep 8, 2014
  44. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    @Reekdeb
    Maybe you can use like this
    Code (CSharp):
    1.  
    2. DOTween.To (
    3.      ( ) => renderer.material.GetColor("_TintColor"),
    4.       x => renderer.material.SetColor("_TintColor", x),
    5.      targetColor, time );
    6.  
     
  45. Reekdeb

    Reekdeb

    Joined:
    Nov 26, 2012
    Posts:
    6
    @shlepsheed
    Thanks for reply. I already tried it. It works when called directly. But it did not work for me because I was calling it inside a loop. Hopefully my problem is solved now.
    In Support & FAQ > Tips section see "Always kill a tween before its target is destroyed, or enable safeMode and let DOTween take care of it." So, target's were being destroyed automatically when called inside a loop like this:
    Code (CSharp):
    1. void Animate()
    2. {
    3.     foreach (var mat in mats)
    4.     {
    5.         DOTween.To(() => mat.GetColor("_TintColor"), x => mat.SetColor("_TintColor", x), Color.black, 5);
    6.     }
    7. }
    8.  
    To solve this pass reference to material through another method:
    Code (CSharp):
    1. void Animate()
    2. {
    3.     foreach (var mat in mats)
    4.     {
    5.         Tween(mat);
    6.     }
    7. }
    8.  
    9. void Tween(Material target)
    10. {
    11.     DOTween.To(() => target.GetColor("_TintColor"), x => target.SetColor("_TintColor", x), Color.black, 5);
    12. }
    13.  
    Edit: See much simpler solution below http://forum.unity3d.com/threads/do...ine-alpha-now-open.260692/page-3#post-1766041
     
    Last edited: Sep 9, 2014
  46. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.170
    • NEW: Added Delay() method, to get a tween's delay
    • NEW: Implemented AxisConstraint option for Vector4 tweens
    • CHANGE: Safe mode is now active by default
    • BUGFIX: Fixed Sequences throwing errors if a nested callback calls Complete on their same Sequence
    • Various architectural optimizations

    @Reekdeb The solution @shlepsheed wrote is exactly how you should do it. Still, I added to my TODO list "alternate material property shortcuts".

    @shlepsheed This update fixes your issue :)
     
    Last edited: Sep 8, 2014
  47. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @Reekdeb I saw your last post only after posting my update. Actually, the solution is different, and is due to a "bug" in NET 3.5 (which was solved in later versions but has not yet been implemented in the last Unity Mono implementation, though I reckon it should be done soon). The issue is that when inside a for loop, closures might use the last variable instead than the correct one. The solution is this:
    Code (csharp):
    1. void Animate()
    2. {
    3.   foreach (var mat in mats)
    4.   {
    5.     // Reassign variable inside loop
    6.     Material m = mat;
    7.     // Using the reassigned variable the tween will work correctly
    8.     DOTween.To(() => m.GetColor("_TintColor"), x => m.SetColor("_TintColor", x), Color.black, 5);
    9.   }
    10. }
    (I noted that I'll have to write this somewhere on DOTween's website)

    P.S. this issue doesn't happen when using shortcuts, since they already reassign the variable and Net/Mono understands it's a different thing
     
    Last edited: Sep 8, 2014
  48. Reekdeb

    Reekdeb

    Joined:
    Nov 26, 2012
    Posts:
    6
    Thank you @shlepsheed for your input and thank you @Izitmee now it is much simpler solution and does not require additional methods. :) It should be done that way. Perviously HOTween and now DOTween, these are my favorite tweeners.
     
    Last edited: Sep 9, 2014
  49. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    Wow thanks for the fast update.

    I got another problem. Now i creating some dialogue system with showing sprite as image in 2D using DOTween for showing the images. So the process is like :
    (A) Show background image ( in Fade In) -> (B) Show character ( in Fade In) -> (C) Show text (in Typewriter animation)
    After A is done, it do B and after its done it do C

    The code is
    Code (CSharp):
    1.  // Fade in
    2. DOTween.FromAlpha (
    3.         ( ) => this.renderer.material.color,
    4.         x => this.renderer.material.color = x,
    5.         0f, 0.5f )
    6.     .OnComplete ( OnShowCompleteCallback );
    7.  
    8. void OnShowCompleteCallback(){
    9.    ProcessToNext();
    10. }
    11.  
    12. void ProcessToNextSequence(){
    13.    DOTween.Complete();
    14.    // Some show and fade in
    15. }
    16.  
    17.  
    It work normaly from A -> B -> C until i put a button that call ProcessToNextLine(). The exception that i got is below. Maybe it just my bad implementation but i want to share it here. Thanks

    Code (CSharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:633)
    3. DG.Tweening.Core.TweenManager.FilteredOperation (OperationType operationType, FilterType filterType, System.Object id, Boolean optionalBool, Single optionalFloat) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:490)
    4. DG.Tweening.DOTween.Complete () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:727)
    5. TestAVisual.OnGUI () (at Assets/TestScript/TestAVisual.cs:20)

    Code (CSharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. (wrapper stelemref) object:stelemref (object,intptr,object)
    3. DG.Tweening.Core.TweenManager.ReorganizeActiveTweens () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:612)
    4. DG.Tweening.Core.TweenManager.Update (Single deltaTime, Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:128)
    5. DG.Tweening.DOTween.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:96)

    Code (CSharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:633)
    3. DG.Tweening.Core.TweenManager.FilteredOperation (OperationType operationType, FilterType filterType, System.Object id, Boolean optionalBool, Single optionalFloat) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:490)
    4. DG.Tweening.DOTween.Complete () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:727)
    5. TestAVisual.OnGUI () (at Assets/TestScript/TestAVisual.cs:20)
     
  50. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @Reekdeb Glad to hear that :)

    @shlepsheed I cannot replicate this issue from the code you posted. Can you post me the full code, or even better a barebone project that replicates the issue?
     
unityunity