I have a VisualElement used as a footprint for all buttons on the bottom of my screen. I want a specific method that I wish to call whenever one of these buttons is pressed. I have already put all of these functions into an array, but I don’t know how to check the buttons from that array.
I have considered running a for loop in Update() that checks every frame if the button is pressed, then calling that method, but this seems rather inefficient. Is there a better way?
Why not just subscribe these methods to said buttons?
Sorry for extremely delayed response - just finished moving. I’m very new to UI Toolkit. How do I subscribe a method to a button (and I figure that means said method is called when the button is pressed?)
All visual elements have a .clicked event delegate property. You just need to get access to the button visual element and subscribe said method. If you’re not sure what I mean there, I would read up on handling C# delegates.