Highlighting UI elements

VisionOS apps need to highlight the UI element people are looking at for a better user experience. How does the highlighting of UI elements work in Unity for the various app types? Does Unity know where the user is looking and based on that highlighting is done normally, kind of like a mouse hover?

We are mainly wondering because Apple has highlighted that user privacy is important and apps will not have access to where the user is looking. Native UI makes this possible by buttons declaring a highlighted state, but it’s not possible to determine from code whether a UI element is highlighted or not.

In Mixed Reality (bounded or unbounded) mode, you can use the PolySpatial Hover Effect component to add a hover effect to GameObjects. This creates a HoverEffectComponent in RealityKit, which is how Apple supports highlighting UI elements (without providing app access to gaze data). The HoverEffectComponent is also created automatically for UGUI components, like Buttons and Dropdowns.

Thanks for the clarification. Does that mean that Unity UI elements will be highlighted, but we would not know that they are highlighted? Or we would actually know which element needs to be highlighted and can respond to it from our own scripts?

What about highlighting stuff (game objects & UI) in windowed apps / shared space? I noticed that neither the Unity UI hovers nor the PolySpatialHoverEffect (since I understood that you have to deactivate PolyPatial for shared space) are working in shared space.

That’s correct. There’s no way of telling what’s highlighted from user code.

Can the highlight visual parameters (color, opacity for example) be modified using the PolySpatialHoverEffect script?

From my current knowledge there is no way to do this. From what has been said at the WWDC talks this highlighting happens at an OS level and your visionOS application does not know that the element has been highlighted

1 Like

Unfortunately, no. We’re limited by the configurability of the underlying HoverEffectComponent, which doesn’t have any options for these settings.

2 Likes

Hi, I’m developing an app in Windowed mode. Is it possible to highlight UI elements in this mode? I can’t use Mixed Reality mode because I need to use BlandShape