Use Gaze Input duration to select UI text in Google Cardboard

穿精又带淫゛_ 提交于 2019-12-11 11:59:52

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/34384382/use-gaze-input-duration-to-select-ui-text-in-google-cardboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!