How do you sync style values in and out of the ui system?

By title I mean let’s say I have a variable in my runtime theme, like a color, and I want to use the same color when constructing a rich text sprite tag somewhere outside of the ui system. Because I found no way to read uss/tss values independent of visual elements (where we have ve.style or ve.resolvedStyle), in this use case the only option I have seems to be to sync the colors by hand, which apparently is less than ideal.

Any suggestions on what should I do, or am I missing any ui toolkit apis to do this?

If you’re on a new enough version of Unity, runtime bindings is an option. Would be a different workflow than using style sheets, but still useful to keep arbitrary data bound.

But as it stands, we can’t currently interface directly with a style sheet via code. Do wish that we could and not sure why we can’t. Honestly not sure why UI Toolkit has to have a completely different way of serialising everything than normal Unity.

1 Like