Uploaded by david.arrowsmith

Here-gaze click in Unity game

advertisement
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.
Download