Bypassing and ignoring Default.uss in it’s entirety (because color inheritance is impossible with it for text elements).
First I will point out the following:
- in HTML/CSS, a div below body will inherit colors from body or it’s parent element unless styled.
- this is one the the most trivial things in HTML/CSS, but a nightmare in UITK.
- In UITK Documentation it is explicitly mentioned that Color is inherited.
- Color keywords on non-text elements are useless if a text element does not inherit color from it’s parent container.
In a custom TSS I have elected to avoid Default.USS. Text element classes are a recurring issue with overrides.
Without a Default.USS, I have a new TSS with a stylesheet with the following rules:
* .unity-text-element
{
color: inherited;
}
.aa-root
{
/* there are labels nested below my .aa-root, I fully expect them to inherit THIS color*/
color: red;
}
What the UIDebugger tells me, is that it recognizes the color should be inherited on text elements:
The root container (.aa-root) has it’s color resolved correctly as well
And it show on the resolved styles correctly for .aa-root itself:
But any label nested below the root element does not inherit the parent’s color: only .aa-root defines a color currently.
Here is the heirarchy:
How color is resolved on .unity-text elements (red is expected here). If this was HTML/XHTML/UML or any other HTML inspired UI toolkit this would be resolving to red. It isn`t even inheriting the default color from the PanelSettings root (#DefaultPanelSettings).
So what is up with this whole inheritance thing? Is the documentation wrong?
It really doesn`t seem to work in any way whatsoever for text elements. Applying colors specifically to each type of .unity-text-element class directly defeats concept of inheritance in CSS or anything based on it.