Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: michwig on May 18, 2012, 02:58:29 PM

Title: Need help with tweens
Post by: michwig on May 18, 2012, 02:58:29 PM
Currently I have my scene set up to where a tween is triggered when the user clicks a button. I have a main menu right now where when the user clicks the single player button, the level select panel slides down. I know right now it only triggers the tween once. How would I edit the script to make it so that the tween will respond every time the user clicks the single player button? I want to have it so that the menu can alternate between the single player and multiplayer panels and right now, I can't get the tween for the single player panel to replay when the user clicks the button more than once.
Title: Re: Need help with tweens
Post by: Ferazel on May 18, 2012, 03:18:35 PM
Instead of making a billion TweenPosition components for all of the animations that you want, I would recommend having 1 tween object and setting the start/end positions procedurally. Then you can determine what positions you want each panel to start from and end. This code snippet has worked for me. Obviously, pick a XY position that is going to work for your menu.

  1. tweenPositionPanel1.from = new Vector3(300.0f, 0.0f, 0.0f);
  2. tweenPositionPanel1.to = new Vector3(0.0f, 0.0f, 0.0f);
  3. tweenPositionPanel1.Reset();
  4. tweenPositionPanel1.enabled = true;
  5.  
  6. tweenPositionPanel2.from = new Vector3(0.0f, 0.0f, 0.0f);
  7. tweenPositionPanel2.to = new Vector3(-300.0f, 0.0f, 0.0f);
  8. tweenPositionPanel2.Reset();
  9. tweenPositionPanel2.enabled = true;
  10.  
Title: Re: Need help with tweens
Post by: ArenMook on May 18, 2012, 05:17:20 PM
Or just use the "toggle" option on the UIButtonTween.
Title: Re: Need help with tweens
Post by: michwig on May 20, 2012, 12:52:25 AM
where is that option? I can't seem to find it?
Title: Re: Need help with tweens
Post by: michwig on May 20, 2012, 12:54:18 AM
Nevermind, I got it.