1
NGUI 3 Support / How to use Tweens?
« on: December 25, 2014, 03:04:20 AM »
I have 4 separate buttons that I want to fade in and out depending on where my character is standing. As he moves around the world, these buttons might fade in or fade out depending on whether he can enter a building or not. My implementation without any tweens works as expected, I just set the button's gameobject's active state to true or false, and it appears and disappears as expected. However a fade in/out effect would look more professional here.
I tried making use of the Play Tween component, and Tween Alpha component, but it didn't seem to play the Tween. Does it make sense for each UISprite to have a Play Tween and Alpha Tween component? I also tried programmatically adding a Tween Alpha and calling the PlayForward/PlayReverse/ResetToBeginning, but my buttons seem to fade in and out in a manner I can't understand, and also when I mouse over my button, and then mouse away from the button, the button goes invisible. (Maybe the Alpha Tween is setting the UI Button's Color Tween settings, causing it to think the normal state has 0 alpha...)
What's the best way to have buttons with their default/highlight/pressed/disabled tween and also have a tween that can fade in and out the buttons? Maybe I need a parent widget to do the fading, so it doesn't mess with the UI Button's colors?
Also, does setting a Tween's enabled=true property cause it to play? Or what is the right way to play the tween multiple times, but not looping? (Fade in.. sometime later.. Fade out.. sometime later.. Fade in..) Basically, is the enabled field relevant and when do I want to set it true/false? Ideally, my buttons will start totally transparent.. is this a tween setting or other setting?
I tried making use of the Play Tween component, and Tween Alpha component, but it didn't seem to play the Tween. Does it make sense for each UISprite to have a Play Tween and Alpha Tween component? I also tried programmatically adding a Tween Alpha and calling the PlayForward/PlayReverse/ResetToBeginning, but my buttons seem to fade in and out in a manner I can't understand, and also when I mouse over my button, and then mouse away from the button, the button goes invisible. (Maybe the Alpha Tween is setting the UI Button's Color Tween settings, causing it to think the normal state has 0 alpha...)
What's the best way to have buttons with their default/highlight/pressed/disabled tween and also have a tween that can fade in and out the buttons? Maybe I need a parent widget to do the fading, so it doesn't mess with the UI Button's colors?
Also, does setting a Tween's enabled=true property cause it to play? Or what is the right way to play the tween multiple times, but not looping? (Fade in.. sometime later.. Fade out.. sometime later.. Fade in..) Basically, is the enabled field relevant and when do I want to set it true/false? Ideally, my buttons will start totally transparent.. is this a tween setting or other setting?