I´m getting started to making videogames and i have an issue, I have a pause button that worked perfectly inside a ui document. Then I decided to create a winning screen, like when a player reaches 5 points he wins, but i did it in another ui document that is on top of it and i disable and enable it when someone wins. That´s when it stopped working, i thought that it was that my second ui document was forbiddening me to click that button, but i tried almost everything to disable it in every way i found and it still doesn´t work.
Please, help me with this problem.
It’s really difficult to read your post without formatting and screenshots, but try read this topic: Unity UI Button OnClick() Not Working. Normal solutions havent solved
As you’re mentioning UI document, it sounds like you’re using UI toolkit. How are you disabling and enabling the second overlay? Via the UI Document component?
By the script, i decrease it´s opacity and i use the function SetEnabled(), that´s the only one i found usefull for other buttons, i´m already using this function with a pause menu wich i disable and enable when it´s necessary.
If you could tell me wich other functions work the same, or give me other options to disable the second UI document that would be great.
Right, so the overlay is still on top of the other visual elements and is going to be swallowing mouse inputs from the one below it.
You can control whether a visual element accepts or ignore inputs with the picking mode property: Unity - Scripting API: UIElements.VisualElement.pickingMode or via toggling the property with the same name in the UI builder.
Though if you actually want to properly ‘remove’ an overlay, you should either destroy it entirely, or potentially set the root visual element’s style.display = DisplayStyle.None which removes it from any layout or other calculations.