Author Topic: Play Tween & Tween Alpha not working as expected  (Read 7431 times)

danglingneuron

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Play Tween & Tween Alpha not working as expected
« on: January 31, 2014, 11:44:25 AM »
I used NGUI 2.6.4 in a previous project. Now in a new project I am using the latest NGUI 3.0.9f4.

Somehow I cannot achieve some simple effects that I used to do in 2.6.4. Basically its a simple click pause button, bring out paused menu with resume button, click resume button, hide paused menu, show pause button scenario.

1. Empty Parent GameObject A is the parent of a label (player score) and a sprite with button script and collider - this is the pause button. The empty gameobject has a Tween Alpha going from 0 to 1.
2. Empty Parent GameObject B is the parent of a label and a sprite with button script and collider - tis is resume button. The empty gameobject has a Tween Alpha going from 0 to 1

Initially GameObject A is active/visible and GameObject B is inactive/hidden. When I click the sprite on GameObjectA, I want to fadeout/disable GameObjectA and enable/fadein GameObject B and vice versa.
SO I have 2 "Play Tween"s on pause button and on resume button.

 
There are two issues that I am facing.
1. The Alpha fadein/out only seem to work on the first child i.e. on the label
2. The fadein/out effect only works the first time. After the first time it appears and disappears ( no tweening).


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Play Tween & Tween Alpha not working as expected
« Reply #1 on: January 31, 2014, 12:11:08 PM »
Alpha is now cumulative, and you shouldn't use TweenAlpha on an empty game object. If you have a UIWidget on that game object instead (an invisible widget -- ALT+SHIFT+W), you can adjust its alpha instead and it will automatically affect all children.

danglingneuron

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Play Tween & Tween Alpha not working as expected
« Reply #2 on: January 31, 2014, 12:51:45 PM »
Awesome. That solves the first issue. Now all children fade-in and fade-out. What do I do about the second issue.

The tween (fade-in and fade-out) only works the first time. After the first time, it appears/disappears instead of fadein-fadeout, even though the Alpha tweens are set to 1 second transition time.   

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Play Tween & Tween Alpha not working as expected
« Reply #3 on: January 31, 2014, 01:25:12 PM »
I would first update to the latest (you said f4 -- f4 is 4 updates behind). If it still happens, I'd need more details to go on. How you activate your tweens and such.

poolts

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: Play Tween & Tween Alpha not working as expected
« Reply #4 on: May 12, 2014, 06:33:35 AM »
I'm getting the same problem. First time the tween plays it works as expected, second time it plays instantaneously (no tweening).

My current setup is:

1) AlphaTween component is enabled (from = 1, to = 0) at the start causing it to autoplay, which fades out a full screen black sprite when the game loads.
2) I then do switch the from and to properties of the tween (to = 1, from = 0) and then do tween.Play(). On play the values correctly change in the inspector and the background sprite 's alpha value changes to 1, however it does it instantaneously and doesn't tween.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Play Tween & Tween Alpha not working as expected
« Reply #5 on: May 12, 2014, 04:38:24 PM »
Don't change 'from' and 'to' values. Use TweenAlpha.Begin instead. It will set the 'from' value and initialize everything and it will start playing all in one line.