Monthly Archives: September 2016

UIButton and isEnabled color change

As part of my hidden UIWidget stuff, the widget has a few buttons on it that I set the isEnabled flag to false when appropriate.  This had the effect of the button changing over time to a dark gray color when it appears on screen.

I didn’t want the color to transition, I wanted it to start gray when it appeared.  So I added the following lines:

float oldDur = button.duration;
button.duration = 0;
button.isEnabled = false;
button.duration = oldDur;

That did the trick – button appeared gray and didn’t transition.

NGUI and inactive widgets in Unity3D

I have a UITexture that I resize before making it visible in the game view.  The problem I ran into is that when you resize a UIWidget and that widget is currently inactive, then NGUI will not force an update to any collider you have attached to it.

I got around this by adding a call to ResizeCollider() after I enabled the UIWidget.  I’ll keep watching to see if there are other properties not being updated while the UIWidget is inactive.