How I can get uGUI event parameter?

130 Views Asked by At

I'm using new event system, represented in unity 4.6. Here is example on attaching listener to Toggle component. My question is: "How can I get Boolean parameter from On Value Changed(Boolean)?"

Gui representation

Currently I'm forced to keeping link of that Toggle object in code and checked new value from it.

public void OnVRtoggled() {
    var value = toggleVR.isOn;
}

But I think that there must be way of getting boolean value from event. Is that possible?

1

There are 1 best solutions below

4
On BEST ANSWER

In Unity 5.1.2 you just need to add a bool parameter in your callback method

public void OnToggledVR(bool isOn) 
{

}

Select On Value Changed Callback Step 1 Select On Value Changed Callback Step 2