Search Unity

UI and Oculus Quest Hand Tracking

Discussion in 'AR/VR (XR) Discussion' started by bftvtech, Jun 22, 2020.

  1. bftvtech

    bftvtech

    Joined:
    Feb 11, 2020
    Posts:
    27
    Is there a way for buttons to be selected without it being a On Click event? I want to simulate a touchscreen display where UI elements can be activated with the colliders on the Oculus hands when using hand tracking. Looking at the UI Button, as an example, it only has the On Click event.

    Thanks!
     
  2. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    OnClick is nothing magical, you can invoke it yourself any way you like, both from script and in-editor. Watch/read some tutorials on UnityUI and you'll find lots of example of this.

    Depending on how you're trying to make this work / what exactly you want to do, you might need to write a 1-line script - but this will be very well covered in UnityUI / Unity EventSystem tutorials.
     
  3. bftvtech

    bftvtech

    Joined:
    Feb 11, 2020
    Posts:
    27
    With VR, I want to use the collider on the fingers to activate ui buttons, and not a mouse clicking on the button. I'm using Hand Tracking with Oculus Quest, with Oculus integration and the Oculus Android Plugin, so not using the XR plugin this time.

    Thanks again for your help! Off topic - Is SnapAndPlug with XR coming this summer? Looking forward to it!
     
  4. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Yep, as I said - onclick is nothing to do with clicking or mouse or buttons (the name is for convenience). It's just a method. It's a method that - depending on the Unity Event System you have added to your scene - automatically gets invoked in certain cases (the default ES will detect mouse-clicks and call OnClick. By contrast, the XR ES will detect VR controller buttons and call OnClick. You can trivially write your own code that will also call OnClick). You can call the method yourself whenever you want. Or you can customise an EventSystem. Both work great.

    Re: SnapAndPlug - that's the plan :). I got delayed a lot by coronavirus :(.
     
  5. bftvtech

    bftvtech

    Joined:
    Feb 11, 2020
    Posts:
    27
    Makes sense, but I hope you didn't have it yourself!
     
  6. liapl

    liapl

    Joined:
    Jun 27, 2021
    Posts:
    2
    Hey bftvtech,
    do you have a solution for your problem? I want to do exactly the same thing, but I don't know how and Google doesn't help, also I'm pretty new to Unity and VR.
     
  7. Sandramatic

    Sandramatic

    Joined:
    Dec 3, 2021
    Posts:
    4
    I'm trying to do the same thing here, any solutions? Thanks! :)