Author Topic: Need help with tweens  (Read 5932 times)

michwig

  • Guest
Need help with tweens
« 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.

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: Need help with tweens
« Reply #1 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.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Need help with tweens
« Reply #2 on: May 18, 2012, 05:17:20 PM »
Or just use the "toggle" option on the UIButtonTween.

michwig

  • Guest
Re: Need help with tweens
« Reply #3 on: May 20, 2012, 12:52:25 AM »
where is that option? I can't seem to find it?

michwig

  • Guest
Re: Need help with tweens
« Reply #4 on: May 20, 2012, 12:54:18 AM »
Nevermind, I got it.