使用凝视输入持续时间在Google Cardboard中选择UI文本 [英] Use Gaze Input duration to select UI text in Google Cardboard
问题描述
我用自己的UI文本按钮修改了Google Cardboard DemoScene.默认情况下,这些按钮响应Onclick()或点击事件以触发操作.当用户在对象上凝视2秒钟时,我想触发这些操作.
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.
我怀疑我需要在GazeInputModule中添加某种条件语句,但是我不知道如何测量时间.谁能指出我正确的方向?这是正确的方法还是我应该尝试其他方法?这对我来说仍然是很新的,因此即使是基本技巧也非常有帮助!
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!
推荐答案
在这里,我启用了按钮,以便在定时的注视下单击.就我而言,我创建了一个用于加载下一个场景的按钮.
Here's how I enabled a button click on a timed gaze. In my case I created a button to load the next scene.
我在Unity游戏中创建了一个场景,因此我并不是从修改Google Cardboard DemoScene开始的,但是原理是相似的.
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.
-
创建一个名为"LoadSceneButton.cs"的脚本(或任何合适的名称,如"TimedGazeButton.cs",并将其附加到要启用定时注视的按钮上.请参见示例脚本在按钮上,添加事件触发器"组件并设置触发器-请参见屏幕快照定时注视按钮事件触发器
On the button, add the "Event Trigger" component and set triggers - see screenshot Timed gaze button Event Triggers
-
Pointer Enter
到按钮的LoadSceneButton.SetGazedAt
,并选中复选框以传递TRUE
值.这表明用户已开始凝视该对象. -
Pointer Exit
到按钮的LoadSceneButton.SetGazedAt
,然后取消选中该框以传递FALSE
值.这表明用户已停止注视该对象并将标线移动到其他位置.
Pointer Enter
to the button'sLoadSceneButton.SetGazedAt
, and check the box to pass in theTRUE
value. This indicates that user has started gazing at the object.Pointer Exit
to the button'sLoadSceneButton.SetGazedAt
, and uncheck the box to pass in theFALSE
value. This indicates that user has stopped gazing at the object and has moved the reticle somewhere else.
当用户的标线移入按钮时,"LoadSceneButton.cs"将开始计时凝视.注视时间达到特定持续时间后,将调用按钮的
OnClick
事件.如果用户在此时间之前将标线移开,计时器将重置.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.我使用的Unity版本是2016年11月10日发布的Google Daydream技术预览版v5.4.2f2-GVR12,带有Google GVR SDK 1.0.3.
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.
这篇关于使用凝视输入持续时间在Google Cardboard中选择UI文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-