Timed Gaze Input selection trigger for Cardboard?

In a previous project (using Oculus / Unity native VR), I custom-created a gaze-based selection system (ie. a timer is triggered upon entering a raycast collision, and an animated icon shows when the event will trigger if you keep looking at that object); however, it did not use UI / EventSystem / etc.

I’m trying to implement the same sort of setup for Cardboard, but finding it a little cumbersome to trace through all of the different references and instantiations to find where I would place a timer on enter/over event, and then use that to trigger the event when time is up.

Has somebody out there already done this and want to share the code, or is there something on the Asset store that will do this? (It’s a fairly simple task, and I wish the Cardboard components would simply have timed-gaze input as an option; in my case, touching a trigger or remote controller is not possible, I really need a timed gaze input, like this: VR Gaze Input | TALES FROM THE RIFT

I might just try this one, but feel like I’m going to break the way Cardboard is set up and then have to do a lot of customization anyway…)

1 Like

Never mind. I think I was just being too lazy (need more coffee!)

I believe the solution (in case anybody else is looking to do this) is to add this to the GazeInput.cs script that Cardboard uses [might need to do a few other tweaks, but the general idea is this should work]:

void HandleSelection()
    {
        if (pointerEventData.pointerEnter != null)
        {
            // if the ui receiver has changed, reset the gaze delay timer
            GameObject handler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(pointerEventData.pointerEnter);
            if (currentLookAtHandler != handler)
            {
                currentLookAtHandler = handler;
                currentLookAtHandlerClickTime = Time.realtimeSinceStartup + GazeTimeInSeconds;
            }
          
            // if we have a handler and it's time to click, do it now
            if (currentLookAtHandler != null &&
                (mode == Mode.Gaze && Time.realtimeSinceStartup > currentLookAtHandlerClickTime) ||
                (mode == Mode.Click && Input.GetButtonDown(ClickInputName)))
            {
                ExecuteEvents.ExecuteHierarchy(currentLookAtHandler, pointerEventData, ExecuteEvents.pointerClickHandler);
                currentLookAtHandlerClickTime = float.MaxValue;
            }
        }
        else
        {
            currentLookAtHandler = null;
        }
    }

NOTE: I also plan to animate the cursor to show a “countdown” (or, really, a “count-up” circular timer)… in my past project, I did this using a shader that allowed for cutoff based on alpha, and creating the icon as one with a radial alpha gradient. I’m not sure if this is the best method on mobile, however, or if it would give better efficiency to use an animated sprite.

The VR samples that Unity released on the asset store give an example of this too. The code is pretty slick.

I heard that Unity had some VR examples, but couldn’t find them… will take another look

Here’s a link:

1 Like

Yeah, I found em… thanks!

Hello,
I’m trying to implement the time gaze function on the VR Sample package, but i can’t figure it out.
On the example, we have to click for triggering “fire1” and the radial will fill up.
How can i do the same but only when you look at the selection ?
I tried to fake input fire1 but i really don’t think it’s the good solution for this.
I think it’s somewhere near the VRInput.cs …
Thanks for any help on this,
I will continue to search for it and if i find it i will tell you!

Hello Again,
Ok i find it, to do it simply,
Put in SelectionRadial.cs "HandleDown() like this :

        public void Show()
        {
            m_Selection.gameObject.SetActive(true);
            m_IsSelectionRadialActive = true;
            HandleDown();
        }
1 Like

Hello,
I used your solution and it works almost perfectly, thanks! I just can’t figure out why the timer resets with a delay. It needs around 1-2 seconds to reset the selection radial. This way, sometimes it starts my action too fast

2 Likes

Hi,

Anyone try gaze for slider?

1 Like

Is the same…

Locate :
VRSampleScenes/Scripts/Utils/SelectionSlider.cs

And replace … line 177 to 186

private void HandleOver ()
        {
            // The user is now looking at the bar.
            m_GazeOver = true;

            // Play the clip appropriate for when the user starts looking at the bar.
            m_Audio.clip = m_OnOverClip;
            m_Audio.Play();
            HandleDown(); // Here autoclick
        }

Thanks for reply

Works perfeclty, thanks you !

1 Like

https://www.youtube.com/watch?v=zmpZojt1vLY

Hi everyone,

Some help here. I have been trying to use the Gaze input in cardboard instead of the mouse click… Can someone help me convert the click input into gaze with some code or something…

Hey man, did you figure out how to fix the bug of the reset of the selection radial ? It tooks me 1-2 sec also …

Thanks you !

Same here, anyone manage to figure out a work around for this yet? Thanks

I am having issues with the selection method for gaze input. I can get the collision object to verify that it has been selected but then I have to click it with my mouse or any other device I cant get the timed selection module to integrate.

Did you get it to work?