BLACK FRIDAY SALE

days
0
0
hours
0
0
minutes
0
0
seconds
0
0

Not Setting Current Selected on Mouseover

Problem

On mouseover on a selectable component (button, toggle, tab, etc…) the EventSystem.current.currentSelectedGameobject is not set, but when using a keyboard (WASD, arrows), a controller or a gamepad then the component is always selected.

Solution

A selectable has 5 possible states:
1. Normal – not affected by anything and IS interactable
2. Highlighted – a pointer is hovering over it (Pointer Enter was triggered)
3. Pressed – a pointer is down on it (Pointer Down was triggered) OR it was triggered
4. Selected – the selectable is the currentSelectedGameObject in the EventSystem (there can be only one)
5. Disabled – the selectable IS NOT interactable

 

This is not a bug, but the correct behavior.

 

When a mouse over a selectable happens, the Highlighted state is triggered and NOT the Selectable state. After you click with the mouse (or pointer), the selectable goes to the Pressed state and the it becomes Selected (in the EventSystem). 

 

When using a keyboard or a controller or a gamepad, the Highlighted state is not triggered as the selectable goes directly in the Selected state via Unity’s Navigation system, when ‘jumping’ from selectable to another.

So, what you’ve seen happen, is not a bug, but the correct and expected behavior when using these different ways of interacting with a UI (in this case Unity’s UI).

Was this page helpful?
Menus – Tab Bars 2
0
Menus – Tab Bars 2
Menus – Tab Bars 1
0
Menus – Tab Bars 1
UI Pack – Neumorph One
0
UI Pack – Neumorph One
Animated Titles – Minimalist 3
0
Animated Titles – Minimalist 3
Table of contents
Doozy UI
Logo
Shopping cart