Author Topic: Animating UIPanel Alpha property  (Read 4495 times)

Nerosam

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Animating UIPanel Alpha property
« on: May 02, 2013, 04:15:39 PM »
Hi,

Thanks again for a l33t GUI solution. Forgive me if this has been asked a bazilion times elsewhere but ive already spent several hours googling and searching these forums with no answers, loosing hair now.

I looked at the examples provided in the package and see animation objects being used to transition from one window to the other and they all only animate the transformation of the object. What I am looking to do however is not only animate the transformation but the alpha value. I gave this a try by manipulating the "MAlpha" value under the UIPanel Script in unity's animation window but this does not animate even though the slider in the inspector is now automatically being controlled by the animation curve.

All i am trying to do is a simple fade out during the animation. Any help on how to do this would be very much appreciated.

Eagerly anticipating some l33t heros to save mista nerosam from loosing his hair.
« Last Edit: May 02, 2013, 05:00:59 PM by Nerosam »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Animating UIPanel Alpha property
« Reply #1 on: May 03, 2013, 09:59:50 AM »
You can't modify private variables such as mAlpha. Attach an AnimatedAlpha script, and adjust its "alpha" value instead.

Nerosam

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: Animating UIPanel Alpha property
« Reply #2 on: May 04, 2013, 11:01:41 AM »
Brilliant. Thanks!

Just want to add a note for anyone else, it doesnt animate when using the animation window but will animate during gameplay.

MrTact

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 32
    • View Profile
Re: Animating UIPanel Alpha property
« Reply #3 on: June 20, 2013, 11:18:32 AM »
You can make it work in the editor by adding the [ExecuteInEditMode] attribute to the class.

Edit: But don't do that! If you do, then the component proxies the value to the UIPanel. As a consequence of this, when you are scrubbing through your animation, since it automatically puts you in record mode (thank you, crappy deprecated Unity dope sheet tool), it will autogen keyframes for mAlpha anyway.
« Last Edit: June 21, 2013, 02:57:46 PM by MrTact »