Author Topic: UITweener "Run to end"  (Read 2567 times)

fwalker

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
UITweener "Run to end"
« on: September 25, 2013, 04:08:36 PM »
Just curious if there is a way to have the UITween essentially "run to its end". Or is this something we need to roll on our own.

SO if a position tween is translating form X1 to X2 with a 10min duration.  I would want to click the mouse at 1 minute, for example, and have the tween run to it's end and disable it self. Does this make sense?
 

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UITweener "Run to end"
« Reply #1 on: September 25, 2013, 05:55:24 PM »
Aren't you essentially just changing the duration while it's running?

I assume it "runs" to its end position in a short time - say 2 seconds - then just grab the tweener OnClick and set the duration lower.

fwalker

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: UITweener "Run to end"
« Reply #2 on: September 25, 2013, 07:16:12 PM »
Yep I could do that. There are a couple other ways. I was just wondering if it was supported already so I did not have to mess with the NGUI code :(

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UITweener "Run to end"
« Reply #3 on: September 26, 2013, 07:20:41 PM »
I wouldn't really call it messing with NGUI code, since you're just using NGUI - not editing the source files.

If you want it to instantly go to the end position do it like this:

  1. GameObject myMovingGameObject;
  2.  
  3. void OnClick(){
  4. TweenPosition tp = myMovingGameObject.GetComponent<Tweenposition>();
  5. tp.enabled = false;
  6. myMovingGameObject.transform.localPosition = tp.to;
  7. }
  8.  

and if you just want it to make its move faster, then you can override the TweenPosition with a new one.

  1. GameObject go; //the moving one
  2.  
  3. //Earlier
  4. TweenPosition.Begin(go, 600, endPosition);
  5.  
  6.  
  7. void OnClick(){
  8. TweenPosition.Begin(go, 2, endPosition);//overrides the existing tween position.
  9. }
  10.  
  11.