使用 OnInputClicked 方法检测隔空点击并按住

Detecting an air-tap-and-hold with OnInputClicked method

我正在编写一个程序,需要检测长按隔空敲击与快速隔空敲击之间的区别。目前,我正在使用以下代码来检测快速 airtaps:

#region IInputClickHandler
public void OnInputClicked(InputClickedEventData eventData)
{
 // stuff being done is coded here
}
#endregion IInputClickHandler

哪个效果很好,但是是否有类似的代码来检测长按?提前致谢。

检测暂停的方法有很多种。对于通用的按住手势,您可以继承和使用 IHoldHandle 接口。如果你想获得更新状态,你应该使用 IManipulationHandlerINavigationHandler 接口。

如果您在编辑器中进行测试,请改用操纵处理程序,因为您无法在编辑器中测试导航,但它适用于 HoloLens。