[UIBuilder] Button text size reference

Hi
I’m using unity 2019.4 with uibuilder 1.0.0
I have a question about button text size. I’ve set up viewport with full hd resolution and put some buttons on it. (Screen in attachment) And when I set button text size to 100% it seems very small. I thought it would be the height of button. What is the percentage size refers to?
I could set text size in px, but it won’t scale to different screen size.

There’s currently a bug where the % unit does not work for font-size.

That said, you should not make all lengths % just to have the UI scale properly. We have independent scaling options that apply to your entire UI, just like Windows and macOS can scale the UI of all (nice) apps automagically while still having them define their UI in terms of “pixels”. You get this dpi-aware scaling of UI Toolkit for free in the Editor and for runtime, there are several options for scaling in the Panel Settings asset. You should be able to define your entire UI using the px unit and then have everything scale evenly with the scaling settings.

The main purpose of the % unit is for when you want some containers, for example, to take up certain percentages of their host container, as their host container changes sizes. It’s not for scaling of the entire UI.

I ran into a similar situation where I wanted to use percentages because that’s what I am used to. This was somewhat misleading initially because of the bug where it was setting the percentage but then when moved out of the inline style it would break, but eventually I found what I think is the correct setting. I thought I should include my settings here because it is seemingly working for me now:

I think the setting you were referring to was “Scale With Screen Size” in the Scale Mode dropdown, is that correct or am I missing something else as well?

I also fell into a trap of assuming ListView was just a simple list view as the name implies… Definitely looking forward to some more full complicated examples and website documentation.

2 Likes