Tapping on a Button on iOS leaves it in :hover state

Hello there,

I noticed that when a UIToolkit-powered Button is tapped on iOS, it remains in “:hover” state, which is quite annoying because the button retains the associated :hover style even if the user stopped interacting with it. I could reset the USS :hover style attached to it, but I would loose this style it on desktop application where I want to keep the :hover style because the player uses a mouse (and :hover style is relevant in that case).

What I could do is create a workaround by having two USS classes:

.mobile Button:hover {
    # Reset the style
}

.desktop Button:hover {
    # Have a style (e.g. darker background color tint)
}

And then in OnEnable, detect whether I am on mobile or desktop and apply the class accordingly, but it looks quite complicated just to accomplish something that simple.

Am I the only having this issue? Did I miss anything?

Thanks for your help.

Hi!

Can you give info on your Unity setup?

  • Unity version
  • UI Toolkit Package version (if you are using the package)
  • Which input system are you using? Input Manager (Old) / Input System Package (New) / Both ?

It does look like a bug, hover state should be handled directly by the control. Feel free to report this as a bug using Help → Report a bug…

Thanks!

Hello @griendeau_unity and thanks for answering my message. Please find the requested info bellow:

  • Unity version: 2020.3.2f1 (but I had this problem back in previous versions of 2020.x.x, not sure exactly which versions though, I could find this in my Git history if necessary). I also temporarily upgraded to 2021.1.0f1 (which I eventually downgraded for other reasons), and the problem was there.
  • UI Toolkit Package version: Version 1.0.0-preview.14 - February 09, 2021 (latest).
  • Input System: Both

Following your message, I decided to try enabling only the new Input System and I don’t have this issue anymore (I did that in Project Settings > Player > iOS > Active Input Handling to “Input System Package” instead of “Both”). However, I can’t interact with UI using Unity UI (I still have a couple of scenes using it).

For information, a ticket has been open and is visible on the public issue tracker:

1 Like