Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: fwalker on September 25, 2013, 04:08:36 PM

Title: UITweener "Run to end"
Post by: fwalker 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?
 
Title: Re: UITweener "Run to end"
Post by: Nicki 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.
Title: Re: UITweener "Run to end"
Post by: fwalker 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 :(
Title: Re: UITweener "Run to end"
Post by: Nicki 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.