新建脚本ClickEvent,挂在手柄上
private VRTK_ControllerEvents e;
private void OnEnable()
{
e = GetComponent<VRTK_ControllerEvents>();
if (e==null)
{
Debug.LogError("null");
return;
}
e.GripPressed += DoGripPressed;//抓取
e.TouchpadAxisChanged += DoTouchpadAxisChanged;//touchpad事件
}
private void OnDisable()
{
if (e != null)
{
e.GripPressed -= DoGripPressed;//事件必须在此-=
}
}
void DoGripPressed(object sender,ControllerInteractionEventArgs e)
{
GameManager.Instance.HideShell();
}
void DoTouchpadAxisChanged(object sender, ControllerInteractionEventArgs e)
{
Debug.LogError(e.touchpadAngle);//获取touchpad角度值
}
参考VRTK脚本 VRTK_ControllerEvents_ListenerExample