How To Show And Hide Properties Dynamically using UI Toolkit. For Example, a Boolean “A” has properties “A1” and “A2”. If Boolean “A” is true show the properties but if it is false hide the properties.
I have tried doing it but the inspector doesn’t update the UI, as shown in the GIF:
The Unity Inspector doesn’t update in accordance with the bool.
Below is my code:
root.Q<VisualElement>("dependantBox").style.display = theBool ? DisplayStyle.Flex : DisplayStyle.None;
This line of code is inside the function “CreateInspectorGUI”. Not Inside the OnInspectorGUI.
I am using UI Toolkit for the inspector.