Hello,
I am not able to connect a button click on a UI with a callback.
The UI has a button “TestButton”.
In C# on the GameObject ‘MainMenu’ that uses the UI Document with the uxml I use the following code to find and register to the button:
_root = _xml.rootVisualElement;
var testButton = _root.Q<Button>("TestButton");
//Register
testButton.RegisterCallback<ClickEvent>((evt) => { Debug.Log($"Clicked on '"); });
When I debug, the Button gets found (strangely with width:NaN) and the registercall back line is fine.
But If I click the button nothing happens. In Event debugger, the ClickEvent gets raised
I am using the ‘New Input System’ if this is somehow related.
I had to add an EventSystem and the ‘Input System UI Module’