Using the "Dynamic Color" usage hint changes the color displayed. 2022.2.0f1

Disabling and enabling the setting will change the color output. Can also modify the setting in the UI Debugger and see the change live.

The setting also seems to be automatically set whenever a transition changes a color on the element.

I started to experience this after updating from 2022.1.24f1 to 2022.2.0f1.

*Edit: Noticed when altering the background color of a visual element.

1 Like

This is by design. We don’t want to regenerate the geometry every frame where the color changes. That being said, the hint itself should have no effect on the observed background color. Please submit a small repro project through the bug reporter (Help > Report a bug…) and QA will investigate.

Ah, that’s why when I press TAB on a button with transition background-color then it changes color. I fixed it by removing all transitions set onto background-color from my project.

                    bool partialResult = element.styleAnimation.Start(StylePropertyId.BackgroundColor, oldData.backgroundColor, newData.backgroundColor, durationMs, delayMs, easingCurve);
                    if (partialResult)
                    {
                        usageHints |= UsageHints.DynamicColor;
                    }

Line 2306 in ComputedStyle.cs enforces DynamicColor if there is a transition. So there is a new color instead of the original one.

I’ve tried setting my buttons to DynamicColor but when the window opens the color is like the original, it’s only after I press TAB that it changes… I love UI Toolkit but I always have troubles with the navigation part.

Is this for runtime or editor UI? Are you in play mode when the bug happens?

I noticed it in play mode.

And is this for runtime (game view) or editor UI (e.g. an editor window)?

Runtime, happens in build also.

Ok, did you submit a case through the bug reporter? Please post the case # here if you have done so.

I have not, do you still need one?

I have sent one, IN-25671

2 Likes

I noticed the same behavior in 2022.2.1f1, in runtime ui, @AlexandreT-unity do you have an update on this?

@dlorre can you please link the issue tracker or send me the case ID so I can keep tab on this for myself? It’s a rather annoying bug :frowning:

Yes, Unity Issue Tracker - [UI Toolkit] Buttons lose focus background color when cycling through them

1 Like

Is there any ETA on when the initial problem described is getting fixed?

The issue UUM-21405 does not resolve the problem of colors appearing different when using UsageHints.DynamicColor. I’m still experiencing this issue in Unity 2022.2.18f.

It could be this other problem whose fix landed in 2022.2.19:
https://issuetracker.unity3d.com/issues/usage-hints-dynamic-color-shows-incorrect-colors-when-project-is-in-linear-color-space

1 Like

The issue you linked does sound exactly like the problem I am experiencing and updating to 2022.2.20f did indeed fix the issue. Thank you! :slight_smile:

1 Like