Hello,
I’m trying to style a UI Toolkit Button
, specifically add a small animation transition on hover using USS. But whenever I specify a transition-duration, the button gets stuck in the hover state.
[206008-sample.zip|206008]:
USS:
.unity-button:hover {
transition-duration: 0.1s;
}
UXML:
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/UI/StyleSheet.uss?fileID=7433441132597879392&guid=194bdebed2a9f1842b04e9ca60c6583b&type=3#StyleSheet" />
<ui:Button />
<ui:Button />
</ui:UXML>
The UXML contains two buttons and has the USS linked. Other than these two files, I’m doing nothing fancy:
- Empty Gameobject with a UIDocument component
- UnityDefaultRuntimeTheme as the TSS.
- Default Panel Settings
The result can be seen below. In short, the button visuals get stuck in the hover state.