They are greyed out because the Scroller instantiates them as sub-controls. They are not visible in your UXML file hierarchy, but here in the builder to show they are created.
When you select these readonly elements in the Builder, you can see in the Inspector, under StyleSheet, what style classes are matching/applied to them. You can use these classes in your stylesheets to override any default styling.
In the case of low/high buttons, you could for example use the classes named .unity-scroller__slider.unity-scroller__low-button and .unity-scroller__high-button. You can also use the name of the element in your stylesheet, ex. #unity-low-button
Hi!
I was wondering how we can have several different styles for scrollers.
We want several scrollers with different looking in our game.
We can overide the default selector’s styling, but it applies to all scrollers in game because they are all using the the default selector.
However, the settings are all greyed out and we can’t apply our own selectors to it.
It would be awesome if anyone could help!
Exactly, the descendant or child selector should work.
Names would work, or you can have different class names to add to your ScrollView, for the various scroller types, and use descendant or child selector to reach the scroller styling in uss.
Hi, thank you for your reply!
It would be wonderful if you would help elaborate or share some examples.
This is what i’ve tried: I add the code below in my uss file
In the Builder window, I still can’t apply my class to it
Then I’ve also tried highBtn.AddToClassList("my-scroller__high-button"); but it didn’t work either.
I think I am somewhat missing some basic understanding of how it works:(
name of the scrollview (the point in giving it a name was to use it :))
space for the descendant selector
class of the item you want to edit
If you want to modify two things, you can do this I think (I’m not sure) #ScrollView1 .unity-scroller__high-button, #ScrollView1 .unity-scroller__low-button {
Thank you very much!!!
Finally I figured it out!
Say I have a Scrollview called #test-scrollview, and I want to change the style of its horizontal scroller’s dragger.
I can use descendant selector (“Any descendants of the first selector, at any level, that also match the second selector.”) to achieve that.
Since .unity-scroller–horizontal and .unity-base-slider__dragger are already the dragger’s selector,
I can use the code below in .USS to control its style, without affecting other scrollviews’ draggers in my game.
I am web developer, but USS in Unity is real nightmare to styling. It only looks like normal web elements and CSS but in reality it much harder to use, most of the time behavior of Unity VisualElements unpredictable, usual tricks from web dev are not working.
Yes, all my attempts to apply USS to the scroll bar failed, for example if make UP/DOWN buttons smaller, the bar is still the same size and scrollbar got gaps. Such behavior is not expected, all web components will expand and fill gaps, but not in Unity.
Not related to scroll bar behavior:
Empty class - failed compilation. Why? Empty classes is 100% ok in CSS.
any wrong property - will break gui. In normal CSS wrong properties just skipped and never break UI.
Hello! That’s strange, these cases (empty class, wrong property) in a USS file should only produce warnings. I cannot reproduce on the latest version. Which version are you using?