Unity 2023.2.8f1.
Have the following UI tree-structure - see the image below. Uppermost VisualElement and two templated elements as its childs. Each element (parent and children) has its own style “container” defined at a separate style sheet (VisualElement has its own style sheet, and template has its own style sheet also). It seems like styles in the direct hierarchy (not in the parallel branches) conflict with each other.
Here are the styles - first one is for uppermost VisualElement, second one is for the template - remember, they are defined at different style sheets (files), and here I just show them in the same code snippet
.container {
flex-direction: column;
align-items: flex-end;
background-color: rgba(0, 115, 133, 0.26);
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
margin-left: 5px;
}
.container {
flex-direction: row;
justify-content: space-between;
align-items: stretch;
}
For the following results are observed:
- The upper “container” adds background-color to the lower one, even if there is no background-color in the lower one.
- Values for the same style property (like align-items or flex-direction) are overriden in the lower “container”.
- But not all values - for example, margins in the lower “container” are 0, even if they are 5px in the upper one.
So, I see no solid rule here. Some properties are overridden in the lower elements, some not. Only one thing stays clear here - the styles with the same name within the same hierarchy branch conflict with each other. So, there is no style isolation within the same visual tree branch in Unity’s UI Toolkit for today?