1

I have modified the Google Cardboard DemoScene with my own UI text buttons. By default, these buttons respond to Onclick() or tap events to trigger actions. I would like to trigger these actions when the user sets their gaze on the object for 2 seconds.

I suspect I need to add some kind of conditional statement in the GazeInputModule but I can't figure out how to measure the time. Can anyone point me in the right direction? Is this the right approach or should I try something else? This is all still pretty new to me so even basic tips are very helpful!

Backs
  • 24,430
  • 5
  • 58
  • 85
Bradical
  • 11
  • 1
  • 4

1 Answers1

3

Here's how I enabled a button click on a timed gaze. In my case I created a button to load the next scene.

I created a scene in my Unity game, so I didn't start off with modifying the Google Cardboard DemoScene, but the principles are similar.

  1. Create a script named "LoadSceneButton.cs" (or whatever suitable name such as "TimedGazeButton.cs" and attach it to the button you want to enable the timed gaze on. See sample script http://pastebin.com/CXd6HA3C

  2. On the button, add the "Event Trigger" component and set triggers - see screenshot Timed gaze button Event Triggers

    • Pointer Enter to the button's LoadSceneButton.SetGazedAt, and check the box to pass in the TRUE value. This indicates that user has started gazing at the object.
    • Pointer Exit to the button's LoadSceneButton.SetGazedAt, and uncheck the box to pass in the FALSE value. This indicates that user has stopped gazing at the object and has moved the reticle somewhere else.
  3. The "LoadSceneButton.cs" will start timing the gaze when user's reticle moves into the button. Once the gaze time has reached a particular duration, the button's OnClick event is invoked. If the user moves the reticle away before that time, the timer is reset.

The version of Unity I used was Google Daydream Technical Preview v5.4.2f2-GVR12 dated 10th November 2016, with Google GVR SDK 1.0.3.

Eugene Sia
  • 41
  • 4