I used to change the theme rewrite the classes. For example:
original theme uss file
.something-class {
background-color: var(--something-color-1);
}
new theme uss file
.something-class {
background-color: var(--something-color-2);
}
Next, to change the theme, I added a new uss file to uxml
somethingUXML.root.styleSheets.Add(newThemeUSS)
It is clear that there can be many things in a class. So I thought I’d update my way of changing the theme. I thought that I could move the color variables to the usual place and override them, rather than entire classes. For example:
original theme file
:root {
--background-color__something-class: var(--something-color-1);
}
.something-class {
background-color: var(--background-color__something-class);
}
new theme uss file
:root {
--background-color__something-class: var(--something-color-2);
}
For some reason it doesn’t work for all files when I add files from code like this
original theme file
:root {
--background-color__background: var(--background-color-white);
}
#Background {
background-color: var(--background-color__background);
width: 100%;
height: 100%;
position: absolute;
}
new theme uss file
:root {
--background-color__background: var(--background-color-black);
}
But when I add in the editor manually everything works fine. Why doesn’t this work when added from code? How to do it right?