0 votes
by (350 points)
recategorized by

Hello.

I use Unity 2019.4.32f
I use Pico G2 4KS
I use Pico XR Plugin 1.2.5

I try to create a gaze input module to be able to select UI with the head.

I already suceed to make it working with XR Controller + XR Ray Interactor with the controller.

I have created another XR Controller + XR Ray Interactor on the head gameobject. And choose "Head" as a XRNode. It works, I can hover UI. But now I am stuck at "Select the hovered UI when you click on the headset button". I don't know which Select Usage I should use Select Usage

I also tried to make a code like :

if(eventSystem.currentSelectedGameObject != null && Input.GetButtonDown("JoystickButton_0"))
{
    eventSystem.currentSelectedGameObject.GetComponent<Selectable>().Select();
}

but this doesn't work because currentSelectedGameObject is always null

What is the best solution to make a gaze UI module with Unity XR Interaction Toolkit + Pico ?

1 Answer

+1 vote
by (44.8k points)

Dear Developer,

With making a gaze UI module, we recommend the script PXR_UIPointer and you can add the following code to get the UI module:

public GameObject getCurrentTarget()
        {
            return currentTarget;
        }

And you can select UI with the head by :

if (Input.GetKeyDown(KeyCode.JoystickButton0))
        {
            GameObject obj = pointer.getCurrentTarget();
            if (obj!= null)
            {
                //your logic
                DebugHelper.Instance.Log(obj.name);
            }

        }

In addition,there is a demo for you to test:
https://drive.google.com/file/d/1lYkjv5k1fi0phCkNtSOPsV8WdQ5AYesF/view

Hope it helps you.

...