How Do I Hide Screens and Prevent Them From Responding to Events?

I have an application with several screens. I created UI document objects for each screen along with a C# file to manage interactions with the screen. When I want to hide or show them in code I use the display style flex or none. However, the hidden screens still respond to events, and when a button is pressed, the hidden screens display even though they are not supposed to do so.

For example, the logo screen has no user input and just shows for 3 seconds or so and then the title screen is supposed to show. The title screen then has a click any button capacity to show the home screen. However, if I press a button while the logo screen is showing, the home screen shows as if it was just there listening for events, then the title screen shows.

With the old UI system, I could use one object to enable or disable all the screens. Is that the best practice here? I thought UI Toolkit was trying to move us away from a component system for UI to more of an event drive web-like approach to UI.

How do I hide a screen, preclude it from responding to events, and keep hidden when buttons are pressed?

Thanks!

VisualElements that are set to display:none should definitely not be eating any events. When you say that the UI is consuming events, do you just mean that they don’t make it to the objects behind or that specific buttons (that are hidden) are being clicked. For the former, this thread adds some details:

So the full situation is that I am using the new input system and ui toolkit. I attached the new input system to the UI Document game object. Even when the screen was set to display:none, it was still responding to events. My solution was to disable the attached input system whenever the screen was not being shown. This stopped it from responding to events.

Is what I described the intended approach to using the new input system with UI toolkit? Do you have different or better guidance?

Thanks!

You can continue doing what works for you for now. We have an updated API coming in 2023.2+, that will also remove the dependency on uGUI to run Input System with UI Toolkit. Things should be easier then.

Great, thanks! I will be on the lookout for it.