- Home /
UI Toggle OnValueChanged sometimes forces me to select an input.
Hi all,
I have two UI Toggles, set up in pretty much the same way. I added an On Value Changed event to one through the UI and it now looks like this;
This works as expected; when I click the toggle my script receives "true" if the toggle is checked and "false" otherwise. I then added a similar event to the other and it now looks like this;
Notice that check box I've circled in red has appeared and it seems to be asking me to define what input my script should receive. When I run my app like this my script always receives a value of "false" regardless of whether the toggle is pressed. If I check that check box then it always receives a value of "true".
Any idea how I can get this second toggle to act like the first and actually pass the correct value through to my script?
For reference my script looks like this;
public void SetBold(bool enabled)
{
m_bold = enabled;
SetPreviewText(m_previewText);
}
public void SetItalic(bool enabled)
{
m_italic = enabled;
SetPreviewText(m_previewText);
}
Answer by saschandroid · Jun 02, 2016 at 07:10 AM
In 'On Value Changed (Boolean)' change the function you want to call from 'SetBold(bool)' (under 'Static Parameters') to 'SetBold' (under 'Dynamic bool') and it should work like your other toggle button.
Your answer
Follow this Question
Related Questions
Toggle Button Question 0 Answers
Toggle Group event called 2 times Unity UI 1 Answer
Dropdown with multiple active options/choices(toggles)? 0 Answers
Adding Listener to Toggle 1 Answer