Hi, I have no intention for my editor to be viewed with the light theme. Is it possible to force the dark theme in UXML? Otherwise in C# I have to reassign my USS files when my menus load, and I have 15 of these that would need light and dark theme styles… can I just lock my UI to dark theme?
Hello! It is highly recommended to always support both light and dark themes since it makes your tools more accessible (this article may help, there are many others you can find online on this subject).
Highly recommended or mandatory? Ie. There is an option to force dark-mode, but you recommend against using it? Or there is no way to force dark-mode, and therefore light-mode must also be supported?
Actually, how would I go about supporting both light and dark mode? Is there a UXML tag that can conditionally use an alternative USS document? Or is there some form of MediaQuery in USS that would allow me to say “if light-mode, override class with these styles”? Or is there some variable in C# I can check like EditorWindow.isLightMode that I can check before manually swapping which style-sheet I use?
While I understand the UX reasoning behind your recommendation, I still hoped it’d be optional for the one developing it. For an internal team, I was hoping to at least make the window consistent when using it, seeing as it isn’t clear how to actually style it conditionally, at least not in a way that makes sense when working with a DOM. None of the options I mentioned in the previous paragraph seem to exist.
You can style your UI as you wish, of course. You can detect if dark mode is on by checking EditorGUIUtility.isProSkin in C# code and make changes based on it.
As Unity switches theme, the basic styles will switch so if you rely on them, your UI will change with the switch. You’d have to overwrite styles with your own values if you don’t want it to change. Just be aware then that your window will look different from the rest of the Editor if you choose this path.
Ah ty, EditorGUIUtility.isProSkin is perfect. I can swap my stylesheets or simply add one during lightmode to override any instances where I’m using the background-color property in USS.