Search Unity

Trouble clicking on a sprite object

Discussion in 'AR/VR (XR) Discussion' started by MaskedMouse, Mar 25, 2020.

  1. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    In our previous setup we got a script that has an IPointerClickHandler implementation.
    It's a sprite with a mesh collider attached and the camera had a Physics Raycaster.
    Now in our previous setup this works fine, with the XR Ray Interactor it seems quite difficult to set up.
    When I use the XR Simple Interactable script it doesn't seem to invoke the OnActivate.
    The on hover enter and exit works fine but the activate does not.
    I've discovered you require to select it first before it can be "activated". So as a workaround I turned on On Hover Select with a time of 0.1 but if I log the OnSelect event, it never gets called either.
    So I tried setting the Select & Activate both on Trigger but then the OnDeactivate only gets called.

    How to properly set this system up to do something just on Trigger for both UI and Mesh Collider?
    I want to user to just point and click, not to select it first with an other button to then be able to activate it by using the trigger. Something so simple seems so difficult to set up or buggy to begin with.

    edit: even with a cube & a box collider, same issues
    edit2: Reading the code of the XRRayInteractor, XRBaseInteractable & XRInteractionManager it is quite confusing. What exactly is OnSelect / OnActivate for?
    I can work around this by using the OnSelect as Trigger and just use OnSelectExit as an activation mechanism but it is quite confusing with the OnActivate as I thought that event was supposed to be the one handling a "click" type interaction.
     
    Last edited: Mar 25, 2020
  2. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    If you read the docs on the Unity minisite for XR, they explain that OnSelect is the equivalent of a mouse-click, and OnActivate is for: after you have selected, if you want to do an extra / context-sensitive action on the already-selected object.

    IT's a big wall of text and hard to read, from memory this is about 80% of the way down, near the bottom. But TL;DR: use OnSelect, this is what it's intended for.
     
  3. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    yeah it’s large, the documentation i’ve skimmed for the info and also read the OnSelect but didn’t get that out of it.
    But thanks for the information!
     
  4. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    I don't think I noticed it until like the 4th or 5th re-read :).