Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: bigohstudios on January 24, 2013, 10:22:12 PM

Title: UICheckbox that doesn't start out checked will never become visible
Post by: bigohstudios on January 24, 2013, 10:22:12 PM
I'm using UICheckboxes in a project, and I'm finding that if I don't have them start out checked, they will never become visible.  Poking around in the code, I found this line in UICheckbox.cs:

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

If I set the 0f to some positive, non-zero value, the checkbox correctly disappears and will again appear when it should.  However, if it starts out with an alpha of 0, it will never become visible, even though the TweenColor process seems to be doing something (I increased the 0.2 second delay to 20, and I could watch the color tint editor control.  It appeared to move, but the checkbox was never visible).

And this only happens if the checkbox was initially set to not be checked on start.  I forced one that was set to be checked on start to have an alpha of 0, and it worked perfectly normal. 

Hopefully that made sense.  I'm happy to provide any other information you need.  I can get it functioning by editing the line I listed above, but that just feels wrong.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: bigohstudios on January 24, 2013, 10:34:52 PM
Scratch that.  My two checkboxes did work as described above, when they were not paired as a radio button group.

If my 2 checkboxes are paired as radio buttons, then if the one that I added to the scene 2nd does not start out checked, then it will never be visible.


Edit: I had originally said "button" instead of "checkbox".  That was incorrect, because the the controls in question are checkboxes.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: milali on January 24, 2013, 11:19:21 PM
I have experienced this bug also
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: ArenMook on January 25, 2013, 10:43:49 AM
Button or checkbox? I am unclear on what you're doing. Slapping a UICheckbox script on top of a button won't turn it into a radio button, especially if you have the checkbox "Check Sprite" pointing to the button's background -- same object that gets tweened by the UIButton script. UIButton / UIButtonColor script must not use the same object as the Check Sprite on the UICheckbox.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: bigohstudios on January 25, 2013, 10:50:24 AM
My mistake in my reply.  They are definitely checkboxes.  I'll edit that reply to reflect that because it is confusing.

I created the checkboxes using the create widget tool, and I added them to the single panel that I have in the scene.  I then created an empty GameObject to which I parented both checkboxes.  I set each checkbox to use that empty GameObject as the parent.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: ArenMook on January 25, 2013, 10:56:25 AM
I did the same thing on my end and everything works correctly. Make sure the game object you created is on the correct layer (ALT+SHIFT+N shortcut to add a child). Clicking on the 2nd checkbox shows the checkbox and hides the checkbox of the first one.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: bigohstudios on January 25, 2013, 10:57:44 AM
Thank you for the quick reply.  I'll be able to do that check this evening, and I'll report back what I find.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: milali on January 28, 2013, 06:12:03 PM
my set up is a single checkbox on the panel. its a gameplay option using the checkbox as a bool flag.

when its enabled it will tick on and off properly

when its disabled and you enter the screen after its been disabled it won't ever animate on when you click on it.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: ArenMook on January 28, 2013, 09:20:42 PM
What version of NGUI? Like I said, I tried it, can't reproduce it on 2.3.1.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: milali on January 29, 2013, 12:20:18 AM
2.2.7c

3.1 wasn't available to non pro users yet, I'll wait with baited breath for it to be released :)

edit: its out! radness! :) checking now.
Title: Re: UICheckbox that doesn't start out checked will never become visible
Post by: milali on January 29, 2013, 01:41:59 AM
same problem. I have attached a pic of how the layout is setup. so you untick the gameplay option and press back. it disables the gameplay options.

if you then select gameplay options from the parent menu it enables this menu but the checkbox doesn't work.

in 2.3.1 PC standalone.