Author Topic: UIToggle  (Read 69195 times)

lilyac

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIToggle
« Reply #15 on: January 20, 2014, 04:28:15 AM »
understood, thank you !

FXCarl

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIToggle
« Reply #16 on: February 03, 2014, 12:03:09 PM »
How to know who called the callback inside the onChange callback method ?

Write a new script attach to toggle ? is this a "right" way ?

  1.  
  2.         UIToggle toggle;
  3.         GameObject target;
  4.  
  5.         public void OnChange(){
  6.                 target.SendMessage("OnChange", toggle, SendMessageOptions.DontRequireReceiver);
  7.         }
  8.  
  9.  
  10.  

Why not give event a parameter ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIToggle
« Reply #17 on: February 04, 2014, 04:05:52 AM »
  1. public void MyChangeFunc ()
  2. {
  3.     Debug.Log("Toggle: " + UIToggle.current.name + " has state of " + UIToggle.current.value);
  4. }

kaz2057

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: UIToggle
« Reply #18 on: February 11, 2014, 09:19:30 AM »
I see with new update startChecked is public.

Can you explain me the difference between startActive vs startChecked?

what Starting State control?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIToggle
« Reply #19 on: February 11, 2014, 09:05:01 PM »
UIToggle.startsChecked is older (legacy) functionality, kept for consistency. It should actually not be public. UIToggle.startsActive should be used instead. I'll make it hidden again in the next version.

kaz2057

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: UIToggle
« Reply #20 on: February 12, 2014, 08:52:34 AM »
but "statsActive" is equal to "StatingState"?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIToggle
« Reply #21 on: February 13, 2014, 03:20:46 AM »
Yup.

natecope

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIToggle
« Reply #22 on: February 17, 2014, 02:01:07 PM »
It's intentional for it to be called on start. It's done for consistency, to ensure that callbacks are in the proper state and match the toggle.

I'm having an issue with this functionality. The event is fired on startup, and my code reacts when a toggle is changed. How do I get around that? Can I shut this off, or will that cause more issues? Is there a simple way to get around this without modifying NGUI code? I'm sure it's a simple logic change in my code, but I'm brainfarting hardcore right now regarding this.

thank you!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIToggle
« Reply #23 on: February 18, 2014, 10:52:00 AM »
Subscribe to the toggle state change in your own script after you do your initialization. Don't be subscribed from the start.

natecope

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIToggle
« Reply #24 on: February 18, 2014, 12:41:08 PM »
Ah of course, how simple.

Inits happen in either Awake() or Start() in my game manager. Is the end of Start() a suitable place to start recognizing toggles?

Thank you for being responsive, btw. I've run into many assets where the author doesn't bother to answer questions, especially from noobs such as myself. It's appreciated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIToggle
« Reply #25 on: February 20, 2014, 12:51:06 PM »
Start is the best place, yup.

sunspider

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UIToggle
« Reply #26 on: March 04, 2014, 02:26:16 AM »
I've created a tab group, set up the same way as the Tabs demo. Is there a way to toggle between the tabs in the editor, for ease of editing each page?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIToggle
« Reply #27 on: March 04, 2014, 03:37:03 AM »
Select the page object, ALT+SHIFT+A to toggle its active state.

Quen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIToggle
« Reply #28 on: March 06, 2014, 11:03:51 AM »
Hi, I got a question about toggle groups: I use a toggle group to select an answer in a quiz. When a new question shows up, I want the status(value) of all toggles to be false. But once I have selected one answer, I cannot deselect all anymore.
How can I reset the initial state of the whole group by script, so that all answers are deselected?

Thanks in advance!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIToggle
« Reply #29 on: March 06, 2014, 12:20:32 PM »
Set UIToggle.optionCanBeNone = true, and you will be able to set them all to 'false'. Same as setting group to '0'. You will be able to set them all to 'false', and then restore the group afterwards.