Search Unity

HOTween: a fast and powerful Unity tween engine

Discussion in 'Assets and Asset Store' started by Demigiant, Jan 7, 2012.

  1. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    @Izitmee I am using the HOtween Component to setup my tweens visually. I didn't think I am storing the tween references, but I am not sure about that (I am assuming it is?). Does HOtween automatically do this for me? If so, how do I force it to recreate the tweens.

    Thanks!
     
  2. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @TobiasP oh then no, references are not stored by the component. Are you sure that when copy-pasting the scene you didn't get the wrong references (like the HOTween Component still referencing the objects in the other scene)? Also, try to kill all tweens when changing scene (which is always recommended) by just calling
    Code (csharp):
    1. DOTween.Kill();
    If nothing works, attach here a barebone project that replicates this issue and I'll check it out.

    @Ben BearFish got completely derailed today, sorry. Will check the issue you found tomorrow (or the day after: I still don't know if tomorrow I'll take a vacation or not).
     
  3. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    No problem. I don't think what I mentioned is actually a problem. I think my problem is that when in my game a person exits a room I call HOTween.GetAllPlayingTweens(), then I pause all the tweens then when they enter the next room I unpause them all.

    What I should be doing is checking which tween are in the next room and unpause them, then keep the previous room's tweens paused. So my real question is:

    Is there a way to get the current object that the IHOTweenComponent is tweening?
     
    Last edited: Aug 14, 2014
  4. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Sure, IsTweening is the way to go.
     
  5. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    @Izitmee Thanks! That was the trick, "Kill" :)
     
  6. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    Code (CSharp):
    1.  static public void PlayUISlilderEffect(UISlider slider, UILabel label, uint num, float endValue)
    2.     {
    3.         Sequence seq = new Sequence();
    4.         for (uint i = 0; i < num; ++i)
    5.         {
    6.             if (i != 0)
    7.             {
    8.                 seq.Append(HOTween.To(slider, 0, new TweenParms().Prop("value", 0.0f)));
    9.             }
    10.             seq.Append(HOTween.To(slider, 0.5f, new TweenParms().Prop("value", 1.0f).SpeedBased(false).OnUpdate(OnSliderUpdate, slider, label)));
    11.         }
    12.         if (num != 0)
    13.         {
    14.             seq.Append(HOTween.To(slider, 0, new TweenParms().Prop("value", 0.0f)));
    15.         }
    16.         seq.Append(HOTween.To(slider, 0.5f, new TweenParms().Prop("value", endValue).SpeedBased(false).OnUpdate(OnSliderUpdate, slider, label)));
    17.         seq.Play();
    18.     }
    19.  
    20.     static private void OnSliderUpdate(TweenEvent e)
    21.     {
    22.         if (e.parms != null)
    23.         {
    24.             UISlider slider = (UISlider)  e.parms[0];
    25.             UILabel label = (UILabel)  e.parms[1];
    26.             StringBuilder sb = new StringBuilder();
    27.             sb.Append(Mathf.Round(slider.value * 100)).Append("%");
    28.             label.text = sb.ToString();
    29.         }
    30.     }
    I want tween my UISlider use above codes.
    but when i use the same slider to run "PlayUISlilderEffect" some times, the function has some problems..
    so ,can i have some advise.....
     
  7. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    What type of problems does the function have? Tell me more.
     
  8. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    when i use the same slider to run "PlayUISlilderEffect",
    the first time ,it's work ok ,
    but when the tween is not completely,
    i use the same slider run PlayUISlilderEffect second time..
    so, i want the first tween complete right now and play the second tween continue.....
     
  9. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    If you want to force your tween to completion before calling PlayUISliderEffect again, just store it somewhere and then do:
    Code (csharp):
    1. mySequence.Complete();
    before PlayUISliderEffect
     
  10. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    Code (CSharp):
    1.     static private Sequence seq = new Sequence();
    2.  
    3.     static public void PlayUISlilderEffect(UISlider slider, UILabel label, uint num, float endValue)
    4.     {
    5.         //StringBuilder sb = new StringBuilder();
    6.         //sb.Append(Mathf.Round(endValue * 100)).Append("%");
    7.         //label.text = sb.ToString();
    8.         //slider.value = endValue;
    9.         seq.Complete();
    10.         seq.Clear();
    11.  
    12.         for (uint i = 0; i < num; ++i)
    13.         {
    14.             if (i != 0)
    15.             {
    16.                 seq.Append(HOTween.To(slider, 0, new TweenParms().Prop("value", 0.0f)));
    17.             }
    18.             seq.Append(HOTween.To(slider, 0.5f, new TweenParms().Prop("value", 1.0f).SpeedBased(false).OnUpdate(OnSliderUpdate, slider, label)));
    19.         }
    20.         if (num != 0)
    21.         {
    22.             seq.Append(HOTween.To(slider, 0, new TweenParms().Prop("value", 0.0f)));
    23.         }
    24.         seq.Append(HOTween.To(slider, 0.5f, new TweenParms().Prop("value", endValue).SpeedBased(false).OnUpdate(OnSliderUpdate, slider, label)));
    25.         seq.Play();
    26.     }
    27.  
    28.     static private void OnSliderUpdate(TweenEvent e)
    29.     {
    30.         if (e.parms != null)
    31.         {
    32.             UISlider slider = (UISlider)  e.parms[0];
    33.             UILabel label = (UILabel)  e.parms[1];
    34.             StringBuilder sb = new StringBuilder();
    35.             sb.Append(Mathf.Round(slider.value * 100)).Append("%");
    36.             label.text = sb.ToString();
    37.         }
    38.     }
    i change my code like this ...but can't work well,
    the tween can only do once...
     
  11. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    //seq.Append(HOTween.To(slider, 0.5f, new TweenParms().Prop("value", 1.0f).SpeedBased(false).OnUpdate(OnSliderUpdate, slider, label)));
    seq.Append(DOTween.To(() => slider.value, x => slider.value = x, 1.0f, 0.5f).OnUpdate(OnSliderUpdate, slider, label));

    how can i use dotween like hotween's callback params........
     
  12. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    I still have to implement callback params in DOTween, but in the meantime you can use an anonymous function like this:
    Code (csharp):
    1.  
    2. seq.Append(DOTween.To(() => slider.value, x => slider.value = x, 1.0f, 0.5f)
    3.   .OnUpdate(()=> {
    4.     StringBuilder sb =new StringBuilder();
    5.     sb.Append(Mathf.Round(slider.value*100)).Append("%");
    6.     label.text= sb.ToString();
    7.   })
    8. );
     
  13. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36

    1. static private Sequence seq = new Sequence(new SequenceParams().AutoKill(false));
    2. static public void PlayUISlilderEffect(UISlider slider, UILabel label, uint num, float endValue)
    3. {
    4. //StringBuilder sb = new StringBuilder();
    5. //sb.Append(Mathf.Round(endValue * 100)).Append("%");
    6. //label.text = sb.ToString();
    7. //slider.value = endValue;
    8. seq.Complete();
    9. seq.Clear();
    but can't work well,
    the tween can only do once...
     
  14. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Mhmm I'm thinking maybe it might be instead because you actually want to rewind and not to complete the Sequence? I don't know exactly what are the values you want to tween, but remember that HOTween takes a tween's start value from the value the object has when the tween starts. So maybe
    Code (csharp):
    1. seq.Rewind();
    Instead than Complete?
     
  15. makoto_snkw

    makoto_snkw

    Joined:
    Aug 14, 2013
    Posts:
    340
    Should I go for HOTween or DOTween?

    Will HOTween become deprecated on later days?
    Or it will exist side by side with DOTween?
     
  16. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    HOTween will continue to exist and I will continue to support it, but it will become kind of deprecated when DOTween will be out of alpha, simply because DOTween is so much better and I like it much more ;)

    All in all, if I was a user and not the creator, right now I would go with DOTween if I didn't have to do something quick. Otherwise, if I had a close schedule, I would go with HOTween because it's already battle-tested (while DOTween instead is still in alpha and thus bugs still have to come out, plus the path plugin and a few other stuff are not yet implemented).
     
  17. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I'm using the WaitForCompletion in a yield statement, but sometimes due to gameplay I have to kill the tween early. In this case this makes the WaitForCompletion() get stuck waiting. Would it be possible to have WaitForCompletion check for if it is killed/destroyed and return early, or make a separate method for this like WaitForCompletionAndKill.

    [EDIT]
    In the meantime, I'm calling code like this as a workaround:
    Code (csharp):
    1. yield return StartCoroutine(WaitForTargetCompletion());
    2. protected IEnumerator WaitForTargetCompletion()
    3. {
    4.      while(targetPointTween != null && (!targetPointTween.isComplete || !targetPointTween.destroyed))
    5.      {
    6.           yield return null;
    7.      }
    8.      yield break;
    9. }
     
    Last edited: Aug 16, 2014
  18. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    For example:
    i have a "level experience bar"(is a UISlider), when i drink a "Mana Potion", i can "level up with exp bar grow to the endValue", sometimes i drink one "mana potion", i can level up more than one level(ex. i levelup 4), so if beginning, i was level 1 and already have exp 34%, then i drink a "mana potion", so i should get level 4 and have exp 69%,
    so the exp bar should behave "34% - 100%" "0%-100%" "0%-100%" "0%-69%",
    but when the exp bar is tweening, i drink the second "Mana Potion", and i should get level 6 and have exp 30%, so i want the first tweening can get 69% right now and then play second tweening:
    "69%-100%" "0%-100%" "0%- 30%"....
    so i write codes like above, but not work very well..
     
  19. makoto_snkw

    makoto_snkw

    Joined:
    Aug 14, 2013
    Posts:
    340
    I'm using HOTween with HOPath the most now.
    I don't see DOTween have that visual tool yet?

    What do you advice? :D
     
  20. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Ben BearFish Ouch I did the same thing with DOTween, but didn't realize I hadn't with HOTween. Fixed in the latest update (1.3.355), both for WaitForCompletion and WaitForRewind.

    @woshihuo12 Can you see if maybe you encountered a bug with the Clear method? Does something change if you simply create a new Sequence instead than reusing the previous one? If everything stays the same, try to make a barebone project (very barebone and very understandable) that replicates the issue and attach it here, so I can check out what's wrong.

    @princeWIGUAN Well then HOTween for now :D Damn the path plugin is almost the most popular feature of HOTween, and I personally never even used it :D
     
  21. makoto_snkw

    makoto_snkw

    Joined:
    Aug 14, 2013
    Posts:
    340
    @lzitmee I use that for my camera movement in cinematic event.
    HOTween + HOPath is very easy, fast and user friendly so far. :)
    Well, then look forward for visual path editor in DOTween for my future project. XD
     
  22. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    @woshihuo12 Can you see if maybe you encountered a bug with the Clear method? Does something change if you simply create a new Sequence instead than reusing the previous one? If everything stays the same, try to make a barebone project (very barebone and very understandable) that replicates the issue and attach it here, so I can check out what's wrong.

    if create a new Sequence, the second tween will works..
    if reuse the previous one, except for the first tweening, the other will not work.
     
  23. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    @Izitmee will I be able to easily swap, out HOTwen for DOTween in any project contains lots o'tweens? And can you give a percentage on performance enhancement? What is it that you did to make DOT so much better?

    Just so you know, coming from iTween to HOTween, as you know, I am still surprised at how many Tweens I can run on mobile. Looking forward to V2.
     
  24. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    i create a localRotation tween like this:
    Code (CSharp):
    1.         mEnergyBgTweener = HOTween.To(mEnergyBg.transform, 3f, new TweenParms().Prop("localRotation", new Vector3(0, 0, 360), true).Loops(-1).AutoKill(false).Pause().Ease(EaseType.Linear));
    then i play it ..
    Code (CSharp):
    1. mEnergyBgTweener.Play()
    and then i want pause it so
    Code (CSharp):
    1. mEnergyBgTweener.Pause();
    but the rotation can't stoped..
    so how can i do to solve this..
     
  25. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    I just copy pasted your code and Pause is working perfectly. I think you probably have something calling
    Code (csharp):
    1. mEnergyBgTweener.Play()
    continuously, thus breaking every pause you set.
     
  26. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Opps sorry @renman3000 I didn't see your post (Unity forums are still kind of whimsical with notifications with me and a few other guys). Swapping should be easy enough. About performance enhancement it depends on how many tweens you have. When really pushed, DOTween is more than 4X faster than HOTween, but with a small number of tweens it's not even noticeable (still, DOTween's faster startup and the careful containment of GC allocations will be very good even with few tweens)
     
  27. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Hi,
    Just downloaded HOTween. Sounds about what I need, but I cant jsut start right away without understanding of the following aspect (possibly a tutorial request):
    - It is perfectly fine with transforming cubes. But what about moveing a person along the path with proper mecanim animation? Any specifics there? Should I disable root motion? I`m jsut not sure how these 2 animation systems are supposed to work together properly..
     
  28. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    1. @Braza Hi, as long as you animate one property with HOTween and another with Mecanim everything will work perfectly. Issues arise only if you animate the same property at the same time with both. As usual, if you want an advanced Waypoint system I recommend @Baroni's Simple Waypoint System, which implements HOTween and will implement DOTween (HOTween v2) in the future.
     
    Braza likes this.
  29. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Not sure if it is new but I get
    from time to time doing
    Code (CSharp):
    1. List<IHOTweenComponent> objectTweens = HOTween.GetTweensByIntId(toUpdate.Key, true);
    Edit: it was somehow fixed by second "false" parameter for me, but worth checking?..
     
    Last edited: Aug 23, 2014
  30. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Question on implementation of onComplete Callback.

    Does it somehow...interfere with main thread...until transition is finished in the way that may prevent other classes to be Updated? I cant understand why doesn't my other class Update ever trigger untill callback invoked. At least what it looks like.
     
  31. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    I'll check out GetTweensByIntId. That is happening because you have an empty Sequence somewhere, but still I should prevent that error by capturing it. Added to my todo list.

    About onComplete nope, I'm 100% sure it's not interfering with the main thread. Maybe you have your other class disabled (either the Component itself or its gameObject), and you enable it when the callback is invoked? Disabled components/gameObject don't call Update and other default methods.
     
    Braza likes this.
  32. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Hi,
    Could you please assist me with understanding reasons for these exceptions below?
    One specific thing that I could think ofthat might happen is that I delete scene objects from time to time. But I do it only on sequence completion or if (HOTween.GetAllPlayingTweens().Count == 0)
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Holoville.HOTween.Tweener.Startup (Boolean p_force) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:1011)
    3. Holoville.HOTween.Tweener.Startup () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:1000)
    4. Holoville.HOTween.Tweener.Rewind (Boolean p_play, Boolean p_skipDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:940)
    5. Holoville.HOTween.Tweener.Rewind (Boolean p_skipDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:290)
    6. Holoville.HOTween.Tweener.Rewind () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:279)
    7. Holoville.HOTween.Sequence.TweenStartupIteration () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:880)
    8. Holoville.HOTween.Sequence.Startup () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:907)
    9. Holoville.HOTween.Sequence.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:649)
    10. Holoville.HOTween.Core.ABSTweenComponent.Update (Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Core/ABSTweenComponent.cs:954)
    11. Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:2173)
    12. Holoville.HOTween.HOTween.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:728)
    13.  
    14. NullReferenceException: Object reference not set to an instance of an object
    15. Holoville.HOTween.Editor.HOTweenInspector.OnInspectorGUI () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1_Editor/HOTweenInspector.cs:159)
    16. UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:1124)
    17. UnityEditor.DockArea:OnGUI()
    18.  
    19.  
    20. NullReferenceException: Object reference not set to an instance of an object
    21. Holoville.HOTween.Tweener.Startup (Boolean p_force) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:1011)
    22. Holoville.HOTween.Tweener.Startup () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:1000)
    23. Holoville.HOTween.Tweener.Rewind (Boolean p_play, Boolean p_skipDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:940)
    24. Holoville.HOTween.Tweener.Rewind (Boolean p_skipDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:290)
    25. Holoville.HOTween.Tweener.Rewind () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:279)
    26. Holoville.HOTween.Sequence.TweenStartupIteration () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:880)
    27. Holoville.HOTween.Sequence.Startup () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:907)
    28. Holoville.HOTween.Sequence.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:649)
    29. Holoville.HOTween.Core.ABSTweenComponent.Update (Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Core/ABSTweenComponent.cs:954)
    30. Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:2173)
    31. Holoville.HOTween.HOTween.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:728)


    Are there any steps I need to perform before Destroy(onceTweenedObject)? Complete, Kill?
     
    Last edited: Sep 7, 2014
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @Braza. First of all I'd recommend downloading the latest version of HOTween from the website (1.3.355 - I can see you're on an old one because line numbers don't coincide). Then that issue is almost surely related to your tween's target being destroyed while the tween is running. You should always Kill a tween before destroying its target.
     
    Braza likes this.
  34. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Hi! Thanks for quick reply)
    Update - check
    Kill tweens - check
    I've added the following:
    Code (CSharp):
    1.                 List<Tweener> listOfTweens =                 HOTween.GetTweenersByTarget(candidate, true);
    2.                 if ((listOfTweens != null) && (listOfTweens.Count != 0))
    3.                 {
    4.                     foreach(Tweener tw in listOfTweens)
    5.                     {
    6.                         //tw.Complete();
    7.                         tw.Kill();
    8.                     }
    9.                 }
    10.                 Destroy(candidate);
    Still getting:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Holoville.HOTween.Sequence.GetTweenersByTarget (System.Object p_target) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:512)
    3. Holoville.HOTween.HOTween.GetTweenersByTarget (System.Object p_target, Boolean p_includeNestedTweens) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:2063)
    4. ViewManager.ProcessObjectsDisappeaedSinceLastSnapshot () (at Assets/Scripts/Client/ViewManager.cs:367)
    5. ViewManager.OnUnitTweenComplete (Holoville.HOTween.TweenEvent e) (at Assets/Scripts/Client/ViewManager.cs:277)
    6. Holoville.HOTween.Core.ABSTweenComponent.OnCompleteDispatch () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Core/ABSTweenComponent.cs:1180)
    7. Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:2198)
    8. Holoville.HOTween.HOTween.LateUpdate () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:74
     
  35. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Ooops, now you're getting a different error, caused by GetTweenersByTarget encountering an exception because you have an empty Sequence somewhere. I'll check it out tomorrow and take care of catching that exception so no errors are thrown. I'll also see if I can add a KillByTarget method, since getting all Tweeners and killing them will not work correctly if you kill Tweeners that are inside Sequences (since in that case you should kill the Sequence too).
     
    Braza likes this.
  36. Boris-Evtifeev

    Boris-Evtifeev

    Joined:
    Sep 8, 2014
    Posts:
    2
    Nice work! For legals - is license for this code same as license of HOTween ?
     
  37. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW UPDATE 1.3.360
    • HOTween.Kill(target) will now also kill all Sequences that have at least one nested tween with the given target
    • Fixed empty Sequences causing errors with some operations and in HOTween Inspector
    @Braza This update solves your issue. To kill all tweens for a given target just call
    Code (csharp):
    1. HOTween.Kill(myTarget)
    @Boris Evtifeev Vevusio is not on Unity Forums since a while so I can't tell for sure, but I'd say the license must be similar unless there's something different written in the code headers?
     
  38. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Hi! Nice speed)
    Though, I get this now:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Holoville.HOTween.Tweener.Startup (Boolean p_force) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:1037)
    3. Holoville.HOTween.Tweener.Startup () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:1026)
    4. Holoville.HOTween.Tweener.Rewind (Boolean p_play, Boolean p_skipDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:966)
    5. Holoville.HOTween.Tweener.Rewind (Boolean p_skipDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:290)
    6. Holoville.HOTween.Tweener.Rewind () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:279)
    7. Holoville.HOTween.Sequence.TweenStartupIteration () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:886)
    8. Holoville.HOTween.Sequence.Startup () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:913)
    9. Holoville.HOTween.Sequence.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:651)
    10. Holoville.HOTween.Core.ABSTweenComponent.Update (Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Core/ABSTweenComponent.cs:954)
    11. Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:2252)
    12. Holoville.HOTween.HOTween.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:734)
    and the code now looks like:
    Code (CSharp):
    1. foreach(KeyValuePair<int,GameObject> oldPair in oldSceneSnapshotObjects)
    2.         {
    3.             if (!newSceneSnapshotObjects.ContainsKey(oldPair.Key))
    4.             {
    5.                 //remove unvisible objects
    6.                 //TODO: desable/enable rather than destroy instantiate
    7.                 HOTween.Kill(oldPair.Value);
    8.                 Destroy(oldPair.Value);
    9.                 toRemove.Add(oldPair.Key);
    10.             }
    11.         }
     
    Last edited: Sep 8, 2014
  39. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Ouch! Though that is now happening because you have a broken tween somewhere (and it should have nothing to do with the kill-or-not-kill). Can you post the code you're using to create tweens, or even better a sample barebone project that replicates the issue so I can play with it?
     
  40. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    It would be challenging to provide barebone because it is heavily Java server-based... It (server) sends snapshots of the world state. Unity client keeps track of these objects, and performs View update with HOTween if any object on server is reported to be moved or rotated... If snapshots arrive faster than Sequence completes, then I just append it. Otherwise, reset. I try to keep Entities IDs aligned with Sequence IDs. Also I try to reuse Sequences and keep them alive until server reports that Entity is out of sight and needs to be destroyed.

    Lets try with sources first? Ignore everything with "fov". I feel that weak place might be objectTweens[0].

    Code (CSharp):
    1. private void UpdateExistingObject(ISFSObject sfso, KeyValuePair<int,ISFSObject> toUpdate, GameObject obj)
    2.     {
    3.         //update previously visible objects: run transition tweens
    4.         // firstly get sequence, or create one
    5.         List<IHOTweenComponent> objectTweens = HOTween.GetTweensByIntId(toUpdate.Key, false);
    6.         Sequence thisObjSeq;
    7.         if (objectTweens == null || objectTweens.Count  == 0)
    8.         {
    9.             thisObjSeq = new Sequence(new SequenceParms().IntId(toUpdate.Key).OnComplete(OnUnitSequenceComplete, obj));
    10.         }
    11.         else
    12.         {
    13.             thisObjSeq  = objectTweens[0] as Sequence; //TODO: add checks and defence
    14.         }
    15.  
    16.         ISFSArray fovSnapshot = null;
    17.         if (sfso.ContainsKey("fov"))
    18.         {
    19.             fovSnapshot = sfso.GetSFSArray("fov");
    20.         }
    21.  
    22.         Vector3 pos = GetPositionFromSnapshot(toUpdate.Value);
    23.         Quaternion ori = GetOrientationFromSnapshot(toUpdate.Value);
    24.  
    25.         GameObject entity = oldSceneSnapshotObjects[toUpdate.Key];
    26.         if (Vector3.Distance(entity.transform.position, pos) <= mapMgr.mapSideSize/2)
    27.         {
    28.             Debug.Log(DateTime.Now.ToString() + " Same position for entity id: " + toUpdate.Key);
    29.             if (Quaternion.Angle(entity.transform.rotation,ori) <= 5.0f)
    30.             {
    31.                 Debug.Log(DateTime.Now.ToString() + " Same orientation for entity id: " + toUpdate.Key.ToString());
    32.                 return;
    33.             }
    34.             else
    35.             {
    36.                 Debug.Log(DateTime.Now.ToString() + " New orientation for entity id: " + toUpdate.Key + " " + ori.ToString() + " vs " + entity.transform.rotation.ToString());
    37.             }
    38.  
    39.         }
    40.         else
    41.         {
    42.             Debug.Log(DateTime.Now.ToString() + " New position for entity id: " + toUpdate.Key.ToString() + " " + pos.ToString() + " vs " + entity.transform.position.ToString());
    43.         }
    44.         animatingSnapshotTransition = true;
    45.         //must be existing sequence by now. is it playing?
    46.         if(HOTween.IsTweening(toUpdate.Key))
    47.         {
    48.             AppendSquenceWithNewSnapshot(thisObjSeq, toUpdate.Value, entity, fovSnapshot);
    49.         }
    50.         else
    51.         {
    52.             CreateSquenceWithNewSnapshot(thisObjSeq, toUpdate.Value, entity, fovSnapshot, toUpdate.Key);
    53.         }
    54.  
    55.     }
    These 2 last methods:

    Code (CSharp):
    1. private void AppendSquenceWithNewSnapshot(Sequence mySequence, ISFSObject newSnapshot, GameObject obj, ISFSArray fovSnapshot)
    2.     {
    3.         Animator playerAnimator = obj.GetComponent<Animator>();
    4.         if (playerAnimator == null)
    5.         {
    6.             Debug.Log(DateTime.Now.ToString() + " AppendSquenceWithNewSnapshot: playerAnimator is: NULL");
    7.         }
    8.  
    9.         TweenParms twp = TweenParamsFromSnapshot(newSnapshot).Ease(EaseType.Linear).OnComplete(OnUnitTweenComplete, fovSnapshot, obj);
    10.  
    11.         mySequence.Append(HOTween.To(obj.transform, 0.3f, twp));
    12.     }
    13.  
    14.     private void CreateSquenceWithNewSnapshot(Sequence mySequence, ISFSObject newSnapshot, GameObject obj, ISFSArray fovSnapshot, int key)
    15.     {
    16.         Animator playerAnimator = obj.GetComponent<Animator>();
    17.         if (playerAnimator == null)
    18.         {
    19.             Debug.Log(DateTime.Now.ToString() + " CreateSquenceWithNewSnapshot: playerAnimator is: NULL");
    20.         }
    21.  
    22.         TweenParms twp = TweenParamsFromSnapshot(newSnapshot).Ease(EaseType.Linear).OnComplete(OnUnitTweenComplete, fovSnapshot);
    23.  
    24.         mySequence.Clear(new SequenceParms().IntId(key).OnComplete(OnUnitSequenceComplete, obj));
    25.         mySequence.Append(HOTween.To(obj.transform, 0.3f, twp));
    26.         mySequence.Play();
    27.         Animator anim = obj.GetComponent<Animator>();
    28.         if (anim != null)
    29.         {
    30.             anim.SetFloat("Speed", 1.0f);
    31.             Debug.Log(DateTime.Now.ToString() + " Setting running animation");
    32.             //anim.SetFloat("Turn", 0.0f);
    33.         }
    34.  
    35.     }
    If it doesn't smell already, I'll try to create the project for you with some random updates generation without server.
     
    Last edited: Sep 8, 2014
  41. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Mhmm really doesn't seem to smell for now :( But I had an idea, and I'll try to update HOTween to implement it and it should force-fix your issue.
     
  42. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Ok I think I realized what's happening: you must probably be calling some operation on a tween that has been killed. This update I'm attaching should fix it. Let me know.
     

    Attached Files:

    Braza likes this.
  43. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Still getting the same... Sorry)
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Holoville.HOTween.Tweener.Startup (Boolean p_force) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:1037)
    3. Holoville.HOTween.Tweener.Startup () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:1026)
    4. Holoville.HOTween.Tweener.Rewind (Boolean p_play, Boolean p_skipDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:966)
    5. Holoville.HOTween.Tweener.Rewind (Boolean p_skipDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:290)
    6. Holoville.HOTween.Tweener.Rewind () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:279)
    7. Holoville.HOTween.Sequence.TweenStartupIteration () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:890)
    8. Holoville.HOTween.Sequence.Startup () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:917)
    9. Holoville.HOTween.Sequence.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:655)
    10. Holoville.HOTween.Core.ABSTweenComponent.Update (Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Core/ABSTweenComponent.cs:954)
    11. Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:2252)
    12. Holoville.HOTween.HOTween.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:734)
     
  44. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Ouch! Though this is caused by a different thing, specifically a Rewind operation. Can you post the code you're using to Rewind, and most of all how are you rewinding (directly via a tween reference or via HOTween.Rewind - I assume it's the first)?
     
  45. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    The thing is that I never rewind anything... Can this be triggered automatically in any conditions?
     
  46. omatase

    omatase

    Joined:
    Jul 31, 2014
    Posts:
    159
    Izitmee, just new to your HOTween tool. I have a tween that moves an object into position for me and I want to just reverse the same tween to move it back to the original position later rather than making a second tween. I've tried using "PlayBackwards" and "Reverse" but it won't move back. What's the appropriate way to do this? Here's my current, non-working code.

    Code (CSharp):
    1. HOTween.PlayBackwards("ShowMatches");
     
  47. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Braza Can you try the version I'm attaching? It surely prevents the error you're having, but I'm not sure if it will prevent other errors (sorry but since I can't replicate the isse I have to go in trial and error mode).

    @omatase You way of playing backwards is correct. But a tween is automatically killed when complete, so calling operations on it won't have any effect. You have to set it's autoKill property to false (see the docs here), and then you'll be able to control it even after it's done (but remember you'll have to kill it manually when not needed anymore).
     

    Attached Files:

  48. Airan

    Airan

    Joined:
    Sep 11, 2014
    Posts:
    6
    Hi Izitmee,

    Is it possible in HOTween to tween the alpha of a GUI element? I want to fade in/out a GUI button but can't seem to figure out how.
     
  49. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Airan if you can change its color manually then you can also tween it. The problem is that if you're talking about the not-4.6 GUI.Button it doesn't have a color property. What GUI are you using?
     
  50. omatase

    omatase

    Joined:
    Jul 31, 2014
    Posts:
    159
    Thanks Izitmee,

    You've done a nice job on the class reference documentation. Thanks, as well, for the explanation of how to work around the auto kill functionality of a tween. I didn't find a property named AutoKill but I did find one called
    autoKillOnComplete. Is this the correct property?

    Even after setting autoKillOnComplete to false I can only play the animation once. Here is the code I am using. Maybe I am doing something wrong.

    Code (CSharp):
    1. foreach (var current in HOTween.GetAllTweens().Where(a => new List<string>{"ShowMatches", "HideMatches"}.Contains(a.id)))
    2. {
    3.     current.autoKillOnComplete = false;
    4. }
    I am setting this property to false before the animation is played. I don't know, maybe my method of accessing the tween is causing the problem?