Author Topic: Checkbox Group on Init Startup.  (Read 5805 times)

NGUIJeffS

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Checkbox Group on Init Startup.
« on: January 14, 2014, 02:48:05 PM »
This may have been covered in http://www.tasharen.com/forum/index.php?topic=171.msg815#msg815 but I don't see any UICheckbox script. My Checkboxes have a UIToggle script, bit there is no Awake functions in it. Which script am I modifiying?

Anyway, here is my problem, which may or may not be fixed by the solution above. I'm trying to use a check box group to select a specific AudioClip to play via a separate IUButton sprite.  So, the UIButton sprite has a play sound script attached to it that I've created that plays a sound specified by a checkbox. I set an audioClip variable based on the checkbox that is selected  (one audio clip per check box using a group of checkboxes). Once I set the audioClip using a checkbox from the the checkbox group I can then press the UIButton and it will play the audioClip.

Everything is working pretty well except on initialization/start up.  On start up the "On Value Change" of the UIToggle script activates for all of the check boxes and I'm not sure why. The "On Value Change" seems to be called/activated even though I've specified the startup state of the check boxes using the "starting status" selection for each box. So, is there a way to disable this initial state change ("On Value Change") in the Check boxes or is do you have any ideas on how I could ignore the first state change to all the Check boxes in the Check box group?

Hope I've explained things clearly. Any help you can offer is greatly appreciated.
I'm working with Unity3.4 and NGUI 3.0.7.

P.S. Your latest video on NGUI 3.0.7 was the best one so far. Thank you.

ivomarel

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: Checkbox Group on Init Startup.
« Reply #1 on: January 14, 2014, 06:43:50 PM »
You can add the following code to the receiving class.

  1. if (UIToggle.current.value) {
  2.    //Do whatever you wanna do after a checkbox was set to true
  3. }
  4.  

NGUIJeffS

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Checkbox Group on Init Startup.
« Reply #2 on: January 23, 2014, 03:07:28 PM »
Thanks or this. I tried resetting check checkbox initial state in the inspector and the issue resolved itself. Not sure why. I'd rather know why, but at least it's working.
Thanks again. I may need this in the future.

NGUIJeffS

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Checkbox Group on Init Startup.
« Reply #3 on: February 03, 2014, 01:54:27 PM »
Thank you. I do need this code after all. Very helpful.