Author Topic: Animate OnPress UIButton Alpha for 2 seconds  (Read 4250 times)

reis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Animate OnPress UIButton Alpha for 2 seconds
« on: September 19, 2013, 04:51:50 AM »
Hi Guys,
I'm really new to C# and learning as I develop this project which is a big learning curve for me.
So please excuse me if I don't understand.

I Want to basically click a UIButton, and animate the alpha channel to hide then reappear after a duration of time.

Also, would it be possible to tween the animation so that it hides quickly and reappears slowly ( EaseIn ) ?
I  am guessing this would have to somewhere include

UIButtonPlayAnimation with a something like a vector3 ( 0,0,0 ) out and in to create the fast fade out and slow ease in?
Or is my current thinking incorrect? But you're able to see my logic in it? ^_^

Thanks in advance x

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Animate OnPress UIButton Alpha for 2 seconds
« Reply #1 on: September 19, 2013, 04:11:18 PM »
UIButtonPlayAnimation plays pre-recorded animations. I think you're looking to do a tween instead. It's easier than recording an animation when it comes to simple transitions, and you can adjust the curve as you see fit.

reis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Animate OnPress UIButton Alpha for 2 seconds
« Reply #2 on: September 20, 2013, 04:27:51 AM »
Hi, thank you for your support.

I'm still running into some difficulties as I can't figure how to correctly use tween alpha.

I've added TweenAlpha to the objects I want to tween. And added theUIButton Tween to the button.

Then assigning the tween target inside the UIButton Tween to the object that has TweenAlpha script on. Then in the Event Receiver of the UIButton Tween is assigned to the object with the Alpha Tween on.

PS: To have multiple objects with the same tween I've added them into the same group. The butted pressed to hide all the buttons for 3 seconds then reappear, also needs to hide.

Thanks again.
R.
« Last Edit: September 20, 2013, 05:22:28 AM by reis »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Animate OnPress UIButton Alpha for 2 seconds
« Reply #3 on: September 20, 2013, 04:42:13 PM »
What you are trying to do is going to be a lot easier with NGUI 3.0. I suggest you wait a little bit until it's released and try it there. It's quite a bit more intuitive in this regard and you can chain tweens together (one after another etc).

reis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Animate OnPress UIButton Alpha for 2 seconds
« Reply #4 on: September 23, 2013, 03:45:36 AM »
Great thanks Aron, Although I would like to figure out how to use it on this version? sorry if it causes any inconvenience!
Also I'd like to take this chance to say great work on the NGUI.