Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. ilovemypixels

    ilovemypixels

    Joined:
    Oct 16, 2012
    Posts:
    6
    Thanks for your reply, the reason I was posting that warning is due to the scripts listed right at the bottom of it, my project was broken, when I commented out these Tweens listed at the bottom it started working again, basically all my tweens seem broken.

    Some of my Tweens are just instantly moving to their end point rather than tweening, as I say commenting some Tweens out seems to fix other Tweens.

    Could you confirm I am calling them in the right way.

    Really appreciate your help I've been stuck on this for weeks, right near the end of the project.

    Do you offer paid support?
     
  2. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Gaspar That baffles me even more. I investigated for a good while, but Vector3Plugin derives from ABSTweenPlugin<Vector3,Vector3,VectorOptions>, thus the cast should totally be possible since there's no generic types involved. How is your Visual Studio set up? Are you working on lose scripts with UnityVS, or inside a library?

    @ilovemypixels The way you're calling tweens seem correct to me, so there must be something else going on. No paid support needed (but thanks for asking): if you want, write me a PM and I'll tell you my mail so you can send me more data. Or you can write me directly from the form on this page.
     
  3. mfosati

    mfosati

    Joined:
    Apr 24, 2014
    Posts:
    13
    @Gaspar
    @Izitmee

    This is exactly what I was encountering. I am working with a Microsoft dev tech right now. I will keep you updated on any fixes we find.
     
  4. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
  5. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    @Izitmee
    When i build Windows Store Application Unity generates Visual Studio solution for me. I am working there.

    @mfosati
    I have the project to reproduce this bug. You can use it. Or we can send it to Unity/Microsoft
     

    Attached Files:

  6. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    @Izitmee No documentation fixes this time! :D

    Long setup; short question:

    During a level in my game, many animations (of different kinds) can play at a time, and some can cancel out others before beginning. To achieve this, I set unique IDs for animations that can be canceled and Kill(id) the specific ones I want. All fine.

    When a level is reset, I want to kill every running animation, with or without an ID. I can use DOTween.KillAll() for that. Also fine.

    However, I really don't want to kill *every* animation. Just the ones in the level. For example, there can be some animations in the overlayed UI that shouldn't stop, even though the level itself restarted.

    I thought of setting an ID "level" to be used for every animation in the level itself, so that I could Kill("level") and not KillAll, retaining the UI animations. Nevertheless, animations can only have one ID, which would be a problem with the unique IDs. I could also set each ID either to "level" OR the unique ID, and kill all those animations. This would be inconvenient because I would have to save the unique IDs somewhere, which I currently don't need to. :) Same for keeping references to the tweens.

    Is there anything in DOTween that might help this whole situation? Creating "groups" of tweens...? Or am I better off doing the above to kill the tweens?

    Two things that could help in this case would be a method KillAllExcept("ui-tweens") (sounds too specific and of limited usefulness, though), or the possibility of setting a named "group" for the tween. But that's essentially just another ID, so the possibility of having multiple IDs per tween would be best (if memory usage isn't a problem). It's just something to consider. :)

    Either way, I'm prepared to do a lot of killing. :mad: :D

    Thanks!
     
    Last edited: Mar 2, 2015
  7. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    216
    I might suggest a simple workaround

    First create a Tween delegate:

    public delegate Tween tweenDelegate();
    public tweenDelegate TweensThatNeedToBeKilled;
    Then every tween that you create and want to kill later you assign to the delegate:

    TweensThatNeedToBeKilled += myTween1;
    ...
    TweensThatNeedToBeKilled += myTween2;

    And when you need to kill them, just call:
    TweensThatNeedToBeKilled.Kill();
    I didn't test this, so I'm not completely sure it will work.
     
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @CanisLupus Wohoo no documentation fixes! I almost feel disappointed :D

    I would prefer not to add another ID, because it would add 6B to every Tween. Anyway, what @Revolter (kudos to you!) suggested is pretty neat. It won't work like that, but here is a fixed example:
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using DG.Tweening;
    4.  
    5. public class KillDelegate : BrainBase
    6. {
    7.     public Transform[] targets;
    8.  
    9.     IEnumerator Start()
    10.     {
    11.         // The first two will be killed when calling KillDelegateTester.KillTweens(),
    12.         // the last one will not.
    13.         KillDelegateTester.KillTweens += targets[0].DOMoveY(5, 2).Kill;
    14.         KillDelegateTester.KillTweens += targets[1].DOMoveY(5, 2).Kill;
    15.         targets[2].DOMoveY(5, 2);
    16.  
    17.         yield return new WaitForSeconds(1);
    18.  
    19.         // Kill the first two tweens (you can choose whether to complete them or not)
    20.         KillDelegateTester.KillTweens();
    21.         // Clear the delegate
    22.         KillDelegateTester.KillTweens = null;
    23.     }
    24. }
    25.  
    26. public static class KillDelegateTester
    27. {
    28.     public delegate void TweenDelegate(bool complete = false);
    29.     public static TweenDelegate KillTweens;
    30. }
    EDIT: by the way, remember to clear the KillTweens delegate after using it:
    Code (csharp):
    1. KillDelegateTester.KillTweens = null;
     
    Last edited: Mar 2, 2015
    Revolter likes this.
  9. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    @CanisLupus
    @Izitmee
    Just a suggestion. Add predicate version of this function, like:
    Code (CSharp):
    1. DOTween.Kill((target, id) => bool, bool);
    Then it will be possible to do something like this:
    Code (CSharp):
    1. DOTween.Kill((target, id) => id.StartsWith("ui-") || ((target is GameObject) && (target as GameObject).CompareTag("UI")));
     
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Gaspar @mfosati and Windows 8 Phone/Store users

    For issues with Windows 8 Store/Phone, I created a thread here. Please report the issue in detail or subscribe, so the Unity guys may fix it as quickly as possible.
     
  11. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    @Revolter @Izitmee @Gaspar Thanks to everyone for the suggestions! You're awesome.

    I definitely like the delegate approach more than keeping a list of references myself. It's also a more "functional" style, which I tend to like. And thanks for the full example, Daniele. (BrainBase? Skynet? Should we be worried? Don't worry; I won't tell.)

    6KB to every tween? Is that correct? :O I was thinking that the ID would become a HashSet of objects instead of an object, so I didn't expect nearly that much, but I haven't checked DOTween's source code to know how it's used. Anyway, forget that.

    Gaspar's idea to filter the tween control methods is nice. :) I don't know about performance, but I assume it can be implemented without affecting the respective versions without filters.
     
    Revolter likes this.
  12. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @CanisLupus Ahaha forgot to change BrainBase to MonoBehaviour when copy-pasting. It's the base class I use for my tests, and to one day dominate the world. Shhhhh.

    Nonono sorry I mis-wrote! It's 6B not KB! But still, I prefer to avoid even those (6B can accumulate, even if slightly, if you have thousands of tweens running together). And a single string property (or two since there's target also, but they need to be separate anyway) is way better than a HashSet, also because HashSets generate GC allocations when being inspected.

    I'll think about @Gaspar's suggestion, if I can find a light way to implement it :)
     
  13. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    @Izitmee I thought that much about BrainBase. ;)

    Ah, 6 bytes sounds right. Good point about the allocations. :)
     
  14. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Gaspar Hey, just for the sake of it, could you try your test project again, but replacing this:
    Code (csharp):
    1. if (plug as ABSTweenPlugin<Vector3, Vector3, VectorOptions> != null)
    2. {
    3.    Debug.Log("Tween 1");
    4. }
    5. else
    6. {
    7.    Debug.Log("Tween 2");
    8. }
    with a straight direct cast?
    Code (csharp):
    1. Debug.Log((ABSTweenPlugin<Vector3, Vector3, VectorOptions>)plug);
    I asked around and everybody tells me this can only be a Unity/Windows 8 bug. So maybe a direct cast might be worth a try.
     
  15. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    @Izitmee
    I already tried direct cast here(Line 28):
    http://prntscr.com/6bcqsh
    And it was an exception:
    Exception: Unable to cast object of type 'DG.Tweening.Plugins.Vector3Plugin' to type 'DG.Tweening.Plugins.Core.ABSTweenPlugin`3[UnityEngine.Vector3,UnityEngine.Vector3,DG.Tweening.Plugins.Options.VectorOptions]'.
    Type: System.InvalidCastException
    Module: Assembly-CSharp
    InnerException: <No Data>
    AdditionalInfo:<No Data>
    at Controller.Start()
    at Controller.$Invoke0(Int64 instance, Int64* args)
    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
     
  16. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    When destroying my game object it complains about it still being accessed. Shouldn't Kill remove the tween first? I'm assuming it's trying to access OnComplete;

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5. using DG.Tweening;
    6.  
    7. public class YoyoFader : MonoBehaviour {
    8.  
    9.  
    10.     public float Duration = 0.2f;
    11.     public int Loops = 6;
    12.     // Use this for initialization
    13.     void Start () {
    14.         tk2dSprite sprite = GetComponent<tk2dSprite>();
    15.  
    16.         DOTween.To(
    17.             () => sprite.color,
    18.             x => sprite.color = x,
    19.             new Color(sprite.color.r,
    20.                 sprite.color.g,
    21.                 sprite.color.b,
    22.                 0),
    23.             Duration).SetId("instructions").SetLoops(Loops, LoopType.Yoyo).OnComplete(OnComplete);
    24.     }
    25.  
    26.     void OnComplete() {
    27.         DOTween.Kill("instructions");
    28.         if(gameObject)
    29.         Destroy(gameObject);
    30.     }
    31. }
    32.  
    33.  
    Edit:

    any of the following throw the same error:

    DOTween.Kill
    gameObject.SetActive
    Destroy(gameObject);

    Nothing else is working on this gameobject.
     
    Last edited: Mar 3, 2015
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Gaspar whoops sorry. I was so focused on the first part that I didn't see the bottom one.

    @SidarVasco I tried to replicate this but everything works perfectly here. The tween is killed (though there's no need for it: it will be killed automatically in your case without generating any exception) and no errors are reported. Can you copy-paste here the full error report? Maybe it's due to something else.
    Also, as a suggestion, since you just want to fade in/out a color you can use ToAlpha and write less code:
    Code (csharp):
    1.          DOTween.ToAlpha(
    2.             () => sprite.color,
    3.             x => sprite.color = x,
    4.             0,
    5.             Duration).SetId("instructions").SetLoops(Loops, LoopType.Yoyo).OnComplete(OnComplete);
     
  18. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    Thanks,

    The full error :
    Code (csharp):
    1.  
    2. MissingReferenceException: The object of type 'YoyoFader' has been destroyed but you are still trying to access it.
    3. Your script should either check if it is null or you should not destroy the object.
    4. UnityEngine.Component.get_gameObject () (at C:/buildslave/unity/build/artifacts/EditorGenerated/UnityEngineComponent.cs:173)
    5. YoyoFader.OnComplete () (at Assets/YoyoFader.cs:24)
    6. 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:238)
    7. DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:376)
    8. DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:49)
    9.  
     
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @SidarVasco Weird and confusing. A possible explanation I can think of is that you have two YoyoFader on the same GameObject (or one on it and one on a child), and the second is called when its gameObject is already destroyed. Since you're not truly checking if the gameObject is null (I just noticed that, see my code after the paragraph), the second one will try to destroy it even if it's already been destroyed previously, and generate that error (which, from the log, is related to that).
    Code (csharp):
    1. // This won't truly check if a gameObject is not NULL
    2. // (like JavaScript or ActionScript would instead)
    3. if (gameObject)
    4. // This instead will
    5. if (gameObject != null)
    Try to check that and let me know. If the problem still persists, recreate it in a barebone project and send it to me via PM (I own 2DToolkit - and love it, so much that the Pro version will have extra shortcuts for it - so you can include it), so I will check it out.
     
  20. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Just wanted to tell you that DOTween runs perfectly fine on Unity 5.0.0f4 for the PS Vita (native with DevKit, not PSM!) :D
     
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Thank you @BTStone :) And by the way, great news today with Unity 5!
     
  22. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163

    I only have one of them. Double checked. The
    1. if (gameObject)
    Didn't matter either.

    I've done it before in other projects. Is there an order of execution that causes the error?
     
  23. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @SidarVasco At least for DOTween order of execution is not a matter in your case, since you're calling stuff when its complete so even if you destroy his target he doesn't care. If you want, send me that barebone replica I was talking about, and I'll check it out.
     
  24. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Hi,

    Is there any way to be able to orient sprites going through a path depending on the segment they are going on?
    I have seen there is an Enum called path mode that the doc states that is used for this but I have used every combination without any luck.

    Could anybody give a hand here?

    Cheers.
     
  25. Philipps

    Philipps

    Joined:
    Jun 10, 2014
    Posts:
    3
    Hello,

    I have an issue with Windows Store Universal apps on Windows Phone. For some strange reasons the cast in PluginManager.GetDefaultPlugin<Color, Color, ColorOptions> failed on my device. If I run the exact same code as an Windows Phone 8 (not the windows store universal) - everything works fine.

    PluginManager.GetDefaultPlugin is called indirect from SpriteRenderer.DOFade(..)
     
  26. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    I had posted prior about choppy 'first time' tweens [I hope nobody puts that phrase into google!]

    I discovered that a judicously minor 'SetDelay' was the answer. No more stuttering nor jumping when the tween is first fired.

    Code (CSharp):
    1.  private Tweener fadeInTweener;
    2.   void Awake()
    3.   {
    4.   DOTween.Init();
    5.   }
    6.   void Start()
    7.   {
    8.    fadeInTweener = FaderImage.DOFade(0, 0.6f);
    9.   fadeInTweener.SetDelay(0.5f); // THIS HERE MADE ALL THE DIFFERENCE
    10.   }

    I don't rightfully know why it works, but it works for me. Without the SetDelay the tween is choppy. 0.5 seems to be the sweet spot.

    Hope that helps somebody.
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @hexdump Did you chain a SetLookAt to your path tween? That's used to set the orientation, and if you pass just 0.1f as a parameter (like in the last example) it will orient to your path.

    @Philipps That was discovered a few days ago by @Gaspar, and is investigated by Unity since it's a Unity bug (because that conversion is totally legit). If you can, let a note on this thread to evidence that it's not working for you either. The more people reporting, the quicker the Unity people will fix it :)

    @FuguFirecracker That is weird, I will investigate and thanks for the report. Unless... Maybe you were starting a tween immediately as your scene started?
     
  28. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    @Izitmee
    Yup. That is exactly what I'm doing. Scene starts, scene fades in... I use DOTween to handle the transition.
    If this is known and expected behaviour .. carry on ;)

    Oh... Did I forget to say THANKS!!!! I love DOTween!
     
  29. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    Loving it so far! I've run into a bug/user error issue when combining sequences though. I might just be doing things incorrectly:

    1. Create new sequenceA
    2. Create new sequenceB

    Sequence B moves a transform around.

    Sequence A is:

    sequenceA.AppendCallback(() => setting a variable)
    .Append(sequenceB)
    .AppendCallback(() => setting the variable to something else)
    .Append(sequenceB);

    sequenceA.Play();

    With the second call to .Append(sequenceB), I get a bunch of index out of range errors. It works great if I remove that last one. Autoplay is set to off as I don't want my sequence B playing by itself unless it's called.

    Is it illegal to re-use sequences like that??
     
    Last edited: Mar 7, 2015
  30. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    Hi, again Izitmee. Do sequences rewind properly? I get different results calling sequence.kill() + new sequence, compared to sequence.restart(); Is there a particular reason for that? (sequence has canvas group fade + interval + canvas group fade + callback in it, no delay or any other settings). Thanks for help.
     
  31. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @FuguFirecracker When a scene starts there is usually a general initial stutter (or to be more precise, usually the first frame of a scene lasts a lot longer than a regular frame), so even tweens will appear to stutter since they're time-based and not frame-based. That's why the delay you added solves it. Sorry for not pointing this out sooner, but I didn't realize you were running a tween immediately at scene-load until you mentioned the delay.

    @timothyallan I actually never thought of appending the same subsequence more than once, and no one ever did that not even with HOTween, so I never tested it. Good catch :) I'll check it out to understand what could go wrong and eventually allow it (or disallow it).

    @Raimis Hiya. Sequences should indeed rewind properly. But if you do a kill+recreate, the targets of the new Sequence will have a start value that will be equal to the values they had when you killed it. To achieve the same result as a Sequence.Restart() you should do a rewind+kill+recreate (but indeed if you can use the same one and just restart it it's more efficient).
     
  32. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    Ha! Apparently I am an extreme developer :)

    I'll give you a use case, and maybe you could let me know if there's an easier way:

    I've got a text object that has an DOTween animation sequence on it: Sequence A. I create another Sequence B which plays Sequence A, changes the .text of the text object using a callback, and then plays Sequence A again.

    Make sense?
     
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @timothyallan Makes perfect sense. You could also do it with a single Sequence (which doesn't mean I won't investigate repeated subsequences, since it's an interesting usage), like this:
    Code (csharp):
    1. Sequence seq = DOTween.Sequence();
    2. seq.AppendCallback(() => setting a variable)
    3.    .Append(/*a tween*/)
    4.    .Append(/*another tween*/)
    5.    .SetLoops(2)
    6.    .OnStepComplete(()=> {
    7.       if (seq.CompletedLoops() == 1) /* setting a variable */
    8.    });
    P.S. it's 3am here so I'm not testing this directly but just writing it and then running to bed: I hope there are no errors.
     
  34. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    Go to bed!

    Okay, so that way works great. Text A shows, the animation happens, then Text B shows, and the animation happens again. The problem I have now is that I don't know why it does :)

    The first callback sets the text to "text a", then the animation tween happens, then the OnStepComplete fires and sets the text to "text b"... But then the sequence executes again for loop 2 and the first callback -should- set the text back to "text A", but it doesn't.

    What am I missing!?
     
  35. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Thank you! But suddenly I got an easier solution - lambda:
    Code (CSharp):
    1. void ShowScoreText(ExtTextMesh text, Action callback)
    2. {
    3.     DOTween.ToAlpha(
    4.     () => text.gameObject.renderer.material.color,
    5.     val => text.gameObject.renderer.material.color = val,
    6.     1f, scoreNamesAppearanceDuration).OnComplete(() => callback());
    7. }
    Also I want to use DOTween instead of coroutine-based delayed executions because tweens can be easily managed.
    Do you think it's a good idea? If yes, what kind of approach you would recommend?
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW UPDATE v1.0.275
    • CHANGE: The Resources folder containing DOTween Settings has been moved outside DOTween's folder (so symlinks won't share the same settings for each project). If you update, your old settings will be saved and just moved, so you won't lose them
    • NEW: More info is now logged in case a tween fails because of an error inside a callback
    • BUGFIX: Deleted leftover logs
    • BUGFIX: Fixed Sequences with LoopType.Restart not being rewinded correctly between each loop step
     
    Ox_ likes this.
  37. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @timothyallan Ah, you're totally right. While checking that out, I discovered that bug with Sequences and LoopType.Restart I fixed in the update I just released (so I spent time with that instead then checking reusable subsequences: will do that next week).
    That code actually works because when a tween updates, parent callbacks are always called before children's. So in that case the Sequence completes a loop but also restarts a new one (because, if for example the Sequence lasted 1 second, in the previous frame the time was 0.95, and in the next it's 1.05, so there's both a step completion and a restart). Will ponder more about that.

    @Ox_ Indeed using a lambda there is great, but since you're calling an existing callback, signing it as a TweenCallback directly would be slightly (even if very slightly) more performant, because you would avoid creating a new anonymous function that just calls another function.
    If you want to use tweens for delayed execution, you can use the extra method DOVirtual.DelayedCall, which is more performant than creating a whole tween just for a callback :)
     
    Ox_ likes this.
  38. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Thank you but if nothing is created then I can't control it. The main problem with coroutines is that I can't pause or cancel them without some sort of wrapper.
    Is there a way to create non-tweening Tween with a callback?
     
  39. Deleted User

    Deleted User

    Guest

    Just discovering this now.... :)

    Anybody have any examples of UGUI working with DOTween ?

    I'm looking for a fairly basic example I can rip apart that works with UGUI elements, a couple of basic buttons, maybe one button / image tweens into the main screen from offscreen to the left and the other fades in from nothing at the centre of the screen ? Would really appreciate the help as a non-programmer, not sure how to call UGUI elements with DOTween, Thanks.

    Regards
     
  40. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Ox_ oh I see. Then you can create an empty Sequence made only of callbacks (like OnComplete), and you will be able to manipulate it as you wish. That said, I added to my todo list a way to return something controllable from DOVirtual.DelayedCall.

    @playmint I might be able to whip it up tomorrow, though if I won't find the time it might take longer since I'll be traveling. That said, you simply access each UGUI component via its reference (an Image reference if it's an Image, a Text reference for text, etc) and use the relative shortcuts.
    Example:
    Code (csharp):
    1. // Fade in an image over 1 second
    2. myImage.DOFade(1, 1);
    3. // Fade out an image over 1 second
    4. myImage.DOFade(0, 1);
    5. // Change the color of an image over 1 second
    6. myImage.DOColor(Color.red, 1);
    7. // Change the color of a text over 1 second
    8. myText.DOColor(Color.green, 1);
    9. // Change the X position of a UI element over 1 second
    10. // (in this case we use a regular transform reference)
    11. myUIElement.transform.DOMoveX(4, 1);
     
    Ox_ likes this.
  41. Deleted User

    Deleted User

    Guest

    Thanks for that, I did try some basic scripting myself, but it wasn't working out for me, must be the way I was personally calling it. I appreciate the help, and I'll keep looking into it ! :)

    Thanks
     
  42. Deleted User

    Deleted User

    Guest

    So, basically,

    based on your help, I'm able to get this dumb example up and running, I've commented out the DOFade, because I can't get this working, I'm assuming I need to declare another public variable ?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using DG.Tweening;
    4.  
    5. public class MoveImage : MonoBehaviour {
    6.  
    7.     public Transform Image;
    8.    
    9.     void Start () {
    10.  
    11.         DOTween.Init(false, true, LogBehaviour.ErrorsOnly);
    12.  
    13.         // Image.DOFade(0, 1);
    14.  
    15.         Image.transform.DOMoveX(4, 1);
    16.    
    17.     }
    18. }
     
  43. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @playmint To use DOFade you need a reference to an image, not to a transform (and you have to add a "using UnityEngine.UI" line on top. Like this:
    Code (csharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using DG.Tweening;
    5.  
    6. public class MoveImage : MonoBehaviour {
    7.  
    8.     public Image img;
    9.     public Transform trans;
    10.    
    11.     void Start () {
    12.  
    13.         DOTween.Init(false, true, LogBehaviour.ErrorsOnly);
    14.  
    15.         img.DOFade(0, 1);
    16.  
    17.         trans.DOMoveX(4, 1);
    18.    
    19.     }
    20. }
     
  44. Deleted User

    Deleted User

    Guest

    Brilliant, that's the trick, I'm up and running now, thanks. :)

    I'm usually stabbing in the dark with syntax, but always appreciate code samples more, then I can see what's fully needed when calling functions, etc, I'm sure this is incredibly irrelevant to programmers who probably already know this stuff.

    Looking forward to your pro release !

    Regards
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Great :)

    While the docs are good already for programmers, I should definitely make more examples. The only problem is that adding new stuff (or fixing existing one) to DOTween takes so much of my time that I end up un-prioritizing the examples. Will do them sooner or later :)
     
  46. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    @Izitmee - the problem i'm facing is that sequence get stuck at some point. Even though I restart the same sequence it gets stuck after few attempts and callback is never called (last entry in sequence). That's quite odd.
     
  47. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Raimis That is weird. Can you reproduce it in a barebone project and send it to me, so I can check it out? As of now, the possible reasons for a Sequence stopping automatically should be:
    1. one of the tween's targets is destroyed or becomes null
    2. one of the callbacks returns an error
    3. you call DOTween.Kill/Pause somewhere and kill/pause all tweens
     
  48. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW UPDATE v1.0.291
    • Greatly optimized path tweens creation
    • NEW: Added Text.DOText shortcut
    • NEW: DOVirtual.DelayedCall now returns a Tween so it can eventually be stored and paused/killed/etc
    And here is an example of the new DOText shortcut in action (strings could be animated like this even before, with the generic tween method, but now it's more handy):



    @Ox_ DelayedCall now returns a Tween ;)
     
    Ox_, Devil_Inside and FuguFirecracker like this.
  49. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    @Izitmee - doesn't restart restart the tween? I do call pause. Basically I assumed that rewind = just moves the playhead to beginning of animation but does not affect the playback state and restart is rewind + play. Please correct me if i'm wrong (if i'm wrong whats the difference between rewind and restart?)
     
  50. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Raimis Yup, Restart does indeed rewind and play a tween, while Rewind rewinds and pauses it.

    P.S. maybe you're calling Pause after Restart? Or you're trying to restart a tween that has been killed?