Author Topic: How to stop tweens starting automatically...?  (Read 10805 times)

triggly_glix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
How to stop tweens starting automatically...?
« on: September 18, 2013, 05:14:23 AM »
I have setup various tweens on my NGui sprites... Tweening alpha and position... whenever i start the app the tween automatically happens... and if i have 2 tweens on the same object they both try to happen simultaneously. So if i have one position tween for entering the screen and another for exiting... how can i tell them not to play when the object is first activated... and only to play when i want them to??
the same thing happens for my scale or alpha tweens...
i don't seem to see a PlayOnAwake option that's already set anywhere ?
thanks

OnlineCop

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: How to stop tweens starting automatically...?
« Reply #1 on: September 18, 2013, 10:22:44 AM »
While tweens are enabled, they run. If you loop through and disable them (tween.enable = false), the tweens "pause" and re-enabling them will resume them. I use this whenever I pause my game: I simply disable all the tweens, which makes my objects freeze: their color, scale, and position tweens all resume again after I re-enable them:
  1.   public void PauseAllTweens()
  2.   {
  3.     if (gameObject != null) {
  4.       UITweener[] tweens = gameObject.GetComponents<UITweener>();
  5.       foreach (UITweener tween in tweens) {
  6.         tween.enabled = false;
  7.       }
  8.     }
  9.   }
  10.  
  11.  
  12.   public void UnpauseAllTweens()
  13.   {
  14.     if (gameObject != null) {
  15.       UITweener[] tweens = gameObject.GetComponents<UITweener>();
  16.       foreach (UITweener tween in tweens) {
  17.         tween.enabled = true;
  18.       }
  19.     }
  20.   }
  21.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to stop tweens starting automatically...?
« Reply #2 on: September 18, 2013, 01:39:46 PM »
In inspector just turn off the component.