Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Default theme quite ugly in Preview 14

Discussion in 'UI Toolkit' started by perholmes, May 5, 2021.

  1. perholmes

    perholmes

    Joined:
    Dec 29, 2017
    Posts:
    295
    Hi,

    Up until preview 14, I had been designing UI in UI Builder using Editor Dark Theme, and when playing in editor or on device, everything would look the same.

    Now with ThemeStyleSheet files, the UI is very botched when playing. I've created a default runtime theme TSS file and assigned it in panel settings. This the final TSS file:

    Code (CSharp):
    1. @import url("unity-theme://default");
    2. @import url("AppStyle.uss");
    I'd like to know where to get the same default theme as in used in the editor, and which was also the runtime theme prior to preview 14. The current theme has weird defaults for font sizes and colors, which I struggle to override. So in UI Builder, I might see:

    upload_2021-5-5_10-46-17.png

    But when playing using this new default runtime theme, I see:

    upload_2021-5-5_10-47-59.png

    Especially scroll bars are now hideous. They used to be beautiful, thin, rounded boxes. Now they have a Windows 98 vibe:

    upload_2021-5-5_10-48-48.png

    Where do I obtain the same theme as is used in the editor? Why deliberately degrade the new runtime default theme?

    And then there's my apparent inability to override anything in the new default runtime theme, but let's solve one problem at a time.

    I've searched my whole C-drive for USS and TSS files, hoping to find some remnant from before Preview 14, but I'm coming up short.

    I'm basically dead in the water, unless I want to re-implement every single style and every single control completely from scratch. That can't be the intention, because it eats into the benefit of using UI Elements at all.
     

    Attached Files:

    Trigve likes this.
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Hello! The available dark themed style sheet you'd been using was never meant to be used in Runtime and cannot be guaranteed to 100% work. The style sheet that has always been meant to be used in Runtime is the same that you can now find as the ThemeStyleSheet in your project.

    The light and dark basic theme style sheets are meant to be used in Editor only UI and they're applied automatically, depending on the current setting in Unity.
     
  3. perholmes

    perholmes

    Joined:
    Dec 29, 2017
    Posts:
    295
    This really sucks. I now have to reverse engineer all the controls and all the class names to even figure out how to make the scrollbar not look like Windows 95.

    Don't you see that it's totally arbitrary? You've just crippled the runtime stylesheet, with no explanation, no documentation, no rational argument, other than "oh yeah, it's different, sucks to be you".

    Could you at least provide the USS for the editor stylesheet so that people can subset it without having the ENTIRE burden of making a new stylesheet FROM SCRATCH just to not have 1990s scroll bars? Is it really a good enough argument that since a couple of features aren't supported on mobile, you're going to cripple ALL default styling for mobile? With no help, no examples, no references, just being dumped out to sea?

    I think this response is too much of a brush-off. Please provide the USS for the editor stylesheet, and I'll subset it myself.
     
    Trigve and forestrf like this.
  4. perholmes

    perholmes

    Joined:
    Dec 29, 2017
    Posts:
    295
    OK, I'm biting the bullet and going through every element and styling it from scratch, which feels like a fool's errand.

    Consider that most people start their UI design on an editor theme. So everyone is in for the same rude awakening when they see it in the player, because the runtime theme is arbitrarily different.

    It really is a problem that you're closed-sourcing something as simple as a USS stylesheet. Nobody has anywhere to start. I can't wrap my mind around how a USS stylesheet is such a proprietary trade-secret that customers can't even get to use it as a starting point, and to understand your very undocumented UI framework.

    You know, we switched from Unreal because we were tired of digging through the source code because most things aren't documented. But at least we found working examples. But here, we don't even have that. We just have a black box because protecting a stylesheet is more important than helping users get their heads around your framework. Realize that ESPECIALLY because it's pre-release, we need the USS files to see how you're reasoning about it yourselves.
     
  5. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    A couple of things to clarify.
    1. Not releasing the Editor StyleSheets has nothing to do with keeping things proprietary and hidden on purpose. It's entirely a technical limitation/decision/prioritization. Editor StyleSheets are generated from a central set of variables and variants that are shared with the IMGUI style system in order to ensure consistency between the two frameworks. As such, they never actually exist as regular text .uss files. They are shipped as fully imported binary assets.
    2. The Runtime Theme was designed to be easier to override by having as few style overrides as possible, while keeping it functional on all the platforms the runtime support instead of just what the Editor supports. It's spartan by design. (also, Windows 95 was not that bad)
    3. You don't need the text USS file to know where a style comes from, how it's applied, and why one selector overrides another (or not). You can find all this using the UI Toolkit Debugger window. It clearly tells you which selectors are currently applied to your element, where they come from, and what properties each sets. Actually, I would argue that it's harder to use a text USS file for this task compared to the UI Toolkit Debugger. (Btw, you can use the UI Toolkit Debugger inside your UI Builder Canvas by enabling Preview mode in the Builder)
    4. We are aware of and have a fix for the specific issue with the Runtime Theme were it is not properly being marked as a "Unity" theme. We have a flag we set for all Unity themes that makes all selectors in a Unity theme be overridable by any user selector, regardless of the normal selector precedence rules. This bug will make it seem that the Runtime Theme is harder to override than the Editor themes - but it's not impossible. It just means you need to make your selectors are higher precedence. USS precedence rules are the same as CSS, but generally more specific selectors are higher in precedence.
    5. Friendly reminder that the UI Builder has a Theme selector in the Viewport that you can use to preview the Runtime theme inside the UI Builder.
    Nothing is arbitrary. All of these decisions have context that goes beyond your specific use case. We did not optimize for users wanting to recreate the Editor look inside the Runtime. We optimized for users with unique UI theming for their specific project.

    We will look at our priorities and see what can be done to help you with your use case, while weighing against everyone else's use cases. What you're asking for is perfectly reasonable. Just know that it's not as simple as just copy-pasting some USS file from our source code onto Github. There is no USS file. We would need to actually create a new process for generating a USS file, versioning it, and shipping it for older versions of the Editor.
     
  6. Daxten

    Daxten

    Joined:
    Sep 20, 2013
    Posts:
    30
    will there be a nicer theme provided by unity at some point? The current one is still extremly basic
     
  7. perholmes

    perholmes

    Joined:
    Dec 29, 2017
    Posts:
    295
    I ended up not importing a Unity theme at all, and creating a theme where I specific everything from the ground up. The problem otherwise was that it was possible for the Unity theme to create un-overridable settings. And it was difficult to inspect where a styling was coming from. I also felt that the ground was shifting under us too much between versions, but of course it's preview, so it has to be allowed to.

    I still think it would have helped a lot if Unity provided their basic themes as some kind of USS, so you can see how it works and know where to target your overrides. But I understand that this is not how it's structured internally, the default settings don't come from a USS file at all. But the startup cost in getting your head around the theme is high, and it was much lower by simply defining all styles completely from scratch and owning it.