Author Topic: UITweener ResetToBeginning concern  (Read 12005 times)

CBYum

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
UITweener ResetToBeginning concern
« on: January 24, 2014, 06:33:33 AM »
I was very surprised to see that the ResetToBeginning fn was direction specific. If you have functions such as PlayForward and PlayBackward that never change their meaning then I think this should be the same for this function. Perhaps just have a Reset fn that also stops it. I was also surprised that there wasn't a Stop fn too and that I just had to use the enabled flag. Perhaps add one for completeness as you have Play actions.

Thanks

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: UITweener ResetToBeginning concern
« Reply #1 on: January 24, 2014, 07:07:59 AM »
I was just about to post the same thing!

I'd like to see a ResetToBeginning(bool forward) method added, I think this would be more intuitive, otherwise I'm thinking I have to to something like this... tween.Play(dir); tween.ResetToBegining(); tween.Stop();// if there were a stop?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITweener ResetToBeginning concern
« Reply #2 on: January 24, 2014, 08:11:36 AM »
The name is an unfortunate side-effect of me going through and fixing all the "Reset()" functions. Reset() is actually a Unity editor function, so I had to come up with a different name.

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: UITweener ResetToBeginning concern
« Reply #3 on: January 24, 2014, 09:33:53 AM »
so is that a "yeah sure I'll add that little bit of functionality" or a "WhatDaMook? get off my forum!!"?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITweener ResetToBeginning concern
« Reply #4 on: January 24, 2014, 10:28:20 AM »
That's a "if I think of a decent function name I may add it/change it in the future" :P For now I've just updated the documentation for it:
  1.         /// <summary>
  2.         /// Manually reset the tweener's state to the beginning.
  3.         /// If the tween is playing forward, this means the tween's start.
  4.         /// If the tween is playing in reverse, this means the tween's end.
  5.         /// </summary>

CBYum

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: UITweener ResetToBeginning concern
« Reply #5 on: January 24, 2014, 10:51:57 AM »
 :'( A tear for those that follow me and also don't read the documents until things don't work as expected.

My "Reset" solution
  1.                         RootPanel.GetComponent<TweenAlpha>().PlayForward();
  2.                         RootPanel.GetComponent<TweenAlpha>().ResetToBeginning();
  3.                         RootPanel.GetComponent<TweenAlpha>().enabled = false;
  4.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITweener ResetToBeginning concern
« Reply #6 on: January 25, 2014, 02:38:09 AM »
Pro-tip: Always cache things. Never use the same GetComponent more than once in the same function.
  1. TweenAlpha tween = RootPanel.GetComponent<TweenAlpha>();
  2. tween.PlayForward();
  3. tween.ResetToBeginning();
  4. tween.enabled = false;