Search code examples
unity-game-engineunity3d-gui

How I can get uGUI event parameter?


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?


Solution

  • 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