How hide and Unhide with UIElements?

Hello,
In my case, I have windows (visual elements)

  1. Character stat
  2. Inventory weight counter

I want that when the weight of the inventory is 9 out 10.
Inventory counter shows and if it’s below 9 its hides.

So using UI Elements how can I hide “Inventory weight counter(visual element)” leaving “Character stat” enable…

Hi lorddanger!

In UIElements, you can select a specific VisualElement on which you want to change the style by using queries: Unity - Scripting API: UQuery

Here’s a code snippet that fetches the VisualElement named “inventoryCounter” and hides it :
rootVisualElement.Q("inventoryCounter").style.display = DisplayStyle.None;

15 Likes