The buildin icon has the dark version(which prefix with ‘d_’) and light version. But I can not find a way to select the icon between dark and light theme.
Is there a solution? Thanks.
The easiest way to support this would be to use a variable and define its value in two different style sheets, one for the dark mode and one for the light mode. Then, in your control, you can add the correct style sheet based on ```
EditorGUIUtility.isProSkin
We don’t have a way to have optional or contextual stylesheets in the UI Builder / UXML at the moment. So if you need to have styling specific for light and dark modes, you will need to handle that manually, either by:
Adding the style sheets through C# code (works well with custom controls)
Adding the style sheets in the UI Builder (with the drawback that you can only support a single mode at a time, you will still need to deal with that manually somewhere)
One middle ground I usually use is to create a custom control that simply deals with adding the correct style sheets at the root of the document. It’s a small overhead that reduces the amount of manual handling I need to make.
In any case, this is a limitation of our current style sheet workflows and it is definitely something we plan to improve.