Simple code:
Foldout expand = ui.Q<Foldout>("FoldoutExpander");
expand.RegisterValueChangedCallback(evt =>
{
}
The above triggers even when a foldout that is a child of FoldoutExpander changes (yes they have different names).
ChGuidi
2
I had the same issue, I fixed this by adding the callback to the Toggle inside the foldout, like this:
var toggle = expand.Q<Toggle>();
expand.RegisterValueChangedCallback(evt => {});
1 Like
ChangeEvent bubble up, in order to make sure the event was triggered by your foldout and not a child, you can check if evt.target is your foldout:
expand.RegisterValueChangedCallback(evt =>
{
if(evt.target == expand)
{
// ....
}
}
1 Like