I have a Toggle. When the user presses it, I see “IsOn” checking on/off. But the events in OnValueChanged are not triggered.
Here’s a demonstration of the toggle not working:
gg4fqb
And here are the functions I’m calling from the OnValueChanged:
using UnityEngine;
public class TestDebugOfToggle : MonoBehaviour
{
public void IsThisWorking(bool value)
{
if (value)
{
print("Yes, it's working. Truth.");
}
else
{
print("Yes, it's still working, and we're false.");
}
}
public void SaySomething()
{
print("Something");
}
}
Sorry - I just realized, I’m not sure if should have used the Bug prefix in the thead title, or Help Wanted. There are threads with similar issues, but those are years and years old.
Am I missing something? Or is this a years-old Unity bug?
Ok for anyone else who finds this - a workaround while we wait for Unity to fix the issue is to set your toggles/sliders to send events in Editor + Runtime. Toggling the isInteractible property in a script won’t work.
I’ve been going nuts trying to figure out why OnValueChanged is being invoked even when the gameobject is inactive!
I guess at some point I enabled that Enter Play Mode Options. If it weren’t for your post on the very same thread I started two years ago, I’d still be pulling my hair out. Thank you @xthewhitel !