USS selector order bug?

Hi,

I experience the following issue: I have a simple button with an applied custom style (“.button-primary”) and this works well, if the uss and uxml is part of the Assets folder. Since our team is creating component packages for easy reuse in other projects, most of our uss and uxmls are being deployed as package via a scoped registry. Once I install the package via the PackageManager, the UIDocument isn’t being rendered as expected. Some properties like “background-color”, “boarder-width”, padding / margin (see screenshot below) which are set in my custom button-primary class style are being overwritten by the unity-button class style.

Why is a part of the unity-button class style being applied after my custom style if the uxml is part of a package?

Is there a way to manipulate the order in which styles are being applied? Or is there a workaround to fix this?

Best regards,
Daniel

Use .unity-button.button-primary to select (or be more specific). I think it is unfortunate that Unity adds their own classes to default elements; because when they do that, it is become harder to override the Unity’s style =/

1 Like

Thanks a lot. This works. I also think Unity should not add their own classes to default elements or at least make it possible to remove those default classes, which is also not possible atm.

1 Like