How to change the Font Size of a Dropdown

Hi,

I’m using Ui Toolkit and i started to script all UIElements, because I basically want to adjust the Elemnts according to the Screen DPI.
Now I have a Dropdown.
if I change the font size with

style.fontSize = 24;

it only changes the Label, but not the item list in the dropdown. How can I change this font per script?
I also tried to iterate through the children in contentContainer, but it didn’t change the fontsize of the list elements. Any ideas?

Just to be sure, you are aware of the automatic scaling options available in the Panel Settings?

Regarding custom styling for the items in the list of the Dropdown menu, I believe this could be done through style. However, you’ll have to use specific USS selectors to override the default styles. I haven’t tested it, but it would look something like this:

.dropdown-field .unity-list-view .unity-label {
    font-size: 24px;
}

Yes, I’m aware of that - but it’s not really helpfull.

It is not possible to apply q stylesheet at runtime as far as i know. Can you tell me a way to apply this stylesheet on runtime with font size calculated in runtime??

You are saying you want to update the element size based on the screen DPI, can you elaborate more on this ? More specifically which issue are you trying to solve ?

I want all elements to have the same physical size on every device. furthermore it should behave slightly different for example on windows or on a phone, because they have completely other screen size/ratios/orientations which needs a different handling and not just simple scaling.
I’m trying to change the font size of a dropdown field in runtime. This is what I’m trying to resolve. What is unspecific about this?

The Scale Mode “Constant Physical Size” seems to be what you are looking for.

We are looking to add @anon_28705954 -query in the future, enabling the creation of responsive UI more easily. I know it’s not ideal, but in the meantime, you could opt for an approach that uses a different set of stylesheets based on the device orientation and screen size.

I was wondering if your question was specifically about customizing the dropdown, but IIUC, it seems to be more about how to create responsive UI with UI Toolkit.

You are mistaken. I’ve been working with Unity UI for many years now and I figured out, that this is never really working.
My UI is ready and completely working as I intended - except for the dropdown, where I can’t change the font size.