Author Topic: UICheckbox check alpha on startup  (Read 6691 times)

getluky

  • Guest
UICheckbox check alpha on startup
« on: April 24, 2012, 06:48:04 PM »
I noticed a possible bug in UICheckbox. All of my checkboxes (except for one) in a radio group (which I am using in a grid for a big selection grid) have startsChecked off, but start with alpha 1 then animate to 0. Looking at the UICheckbox code, it seems like mStarted is set to true in Start, before Set is called by Start. It doesn't look like the initialization code branch for !mStarted will ever run. Or am I supposed to set start alpha manually?

loopyllama

  • Guest
Re: UICheckbox check alpha on startup
« Reply #1 on: April 24, 2012, 10:18:21 PM »
To make a long story short, this is by design. Save yourself trouble and set the state of the checkbox to myCheckBox.isChecked = false in an Awake function. Then it will not animate off, it will simply be off when you start your app. That special code you point out is the exact code that will help you "turn off" the animation on startup only, when you do the above.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICheckbox check alpha on startup
« Reply #2 on: April 24, 2012, 11:56:07 PM »
Add this to the UICheckbox's Awake function:

  1. if (checkSprite != null) checkSprite.alpha = startsChecked ? 1f : 0f;

getluky

  • Guest
Re: UICheckbox check alpha on startup
« Reply #3 on: April 25, 2012, 04:18:23 PM »
Thanks, that seems like it fixed it.