Author Topic: Panel not rendering after animation  (Read 6723 times)

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Panel not rendering after animation
« on: September 08, 2014, 07:06:59 AM »
Hey,

I have some panels that are instantiated and have animations played (translation and alpha 0-1) as part of a window management system.

Everything works fine the first time, and the panel is created, and animated in. Animation out also works fine.

However when the panel is activated again and the animation plays, the panel remains invisible.

The animation plays correctly, and the panel alpha is animated to 1 and the transform is moved, but nothing is drawn.

Upon changing any property of the panel (nudging the alpha for example) , it becomes visible and everything works as expected.

There are no draw calls present, despite the pane and every widget below it being turned on.

Any help here would be great thanks :)

badawe

  • Jr. Member
  • **
  • Thank You
  • -Given: 8
  • -Receive: 7
  • Posts: 70
    • View Profile
Re: Panel not rendering after animation
« Reply #1 on: September 08, 2014, 07:45:03 AM »
I have this problem here too, since this last 3.7.1 update.

Lets hope the new update come out soon, and fix this issue.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Panel not rendering after animation
« Reply #2 on: September 08, 2014, 10:22:19 PM »
As I've mentioned it many times before, you can't animate private variables. "MAlpha" is a private variable, and the fact that Unity shows it is a bug in Unity. NGUI works through properties, not variables. UIRect.alpha is what you should be animating. To do it via a Unity animation, you need an intermediate script.
  1. using UnityEngine;
  2.  
  3. [ExecuteInEditMode]
  4. [RequireComponent(typeof(UIRect))]
  5. public class AlphaAnimator : MonoBehaviour
  6. {
  7.     [Range(0f, 1f)]
  8.     public float alpha = 1f;
  9.  
  10.     void Update () { GetComponent<UIRect>().alpha = alpha; }
  11. }

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Panel not rendering after animation
« Reply #3 on: September 08, 2014, 11:35:46 PM »
Thanks for that.

badawe

  • Jr. Member
  • **
  • Thank You
  • -Given: 8
  • -Receive: 7
  • Posts: 70
    • View Profile
Re: Panel not rendering after animation
« Reply #4 on: September 09, 2014, 07:47:49 AM »
Hey @ArenaMook let me get this straight.

You should not animate a alpha from a panel? Never?!  :o :o :o

Sorry about this, but I've never read this before! hahah If I use one Widget as a root of all other objects, and change this alpha instead, this will work fine right?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Panel not rendering after animation
« Reply #5 on: September 10, 2014, 12:47:33 AM »
You can animate alpha just fine, but you need to use an intermediate class like I mentioned above.

You should not animate private variables, as Unity doesn't have a notification that says "hey, animation just changed your values, you might want to do something!", so there is no way to know when animation alters something without saving previous values and checking for inequality every update, which is obviously way too much overhead.