Search Unity

Bug XRRayInteractor events are not firing for UI components

Discussion in 'XR Interaction Toolkit and Input' started by jlink, Aug 12, 2021.

  1. jlink

    jlink

    Joined:
    Jan 8, 2017
    Posts:
    11
    I'm trying to trigger haptics through XRRayInteractor when hovering UI components but its hover events don't seem to be firing. I've tried flagging the haptics events, assigning custom haptics methods through the interactor events, as well as just subscribing to those events in code and the hover events just aren't firing for UI components. I can interact with UI components just fine however.

    Is there something I'm missing in setup or is this feature not supported yet?
     
  2. jlink

    jlink

    Joined:
    Jan 8, 2017
    Posts:
    11
    bump
     
  3. freso

    freso

    Joined:
    Mar 19, 2013
    Posts:
    73
    This isn't a bug. UI elements aren't interactables, so you won't get hover events from the Interactor.
    If you want events on UI hover, look into standard UI system hooks.

    If Unity events didn't suck, you'd just attach listeners to Button.hoverEntered, but since Unity sucks, you'll have to create your own ButtonPlus that inherits Button and uses interfaces IPointerEnter/Exit and override OnPointerEnter/Exit(), or some other sucky method.

    Look into UI event handling. Maybe there is a way to add a generic event in the EventSystem for all hovers (PointerEnter/Exit).
     
  4. jlink

    jlink

    Joined:
    Jan 8, 2017
    Posts:
    11
    Oh wow, that sucks. Surely it must be possible though since interactors are sending hover/select events to UI for interaction.

    The issue with hooking into UI button events is that there is no way to know which interactor (controller) is interacting with the button. So for triggering haptics on hover/select from the button events, I would need to reference the interactors and check their states to try and infer which is interacting with the button.

    Anyway thanks for the info. I'm going to dig a bit and see if I can find a better workaround, possibly through a custom interactor that works with UI buttons.
     
  5. freso

    freso

    Joined:
    Mar 19, 2013
    Posts:
    73
    You should definately be able to create an extended RayInteractor by inheriting from XRRayInteractor and implement your own events: uiHoverEntered/Exited.

    I just meant that UI-objects aren't XRBaseInteractable, so you'll have to use other methods. You may be able to find something in XRUIInputModule, or XRInteractionManager.

    (Personally I don't even think RayInteractor should handle UI, but that's another topic ;))