VRTK3.3.0-003发出一条简单射线和监听
Posted myunity
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VRTK3.3.0-003发出一条简单射线和监听相关的知识,希望对你有一定的参考价值。
1丶在Right下继续添加脚本VRTK_Pointer和VRTK_StraightPointerRenderer
运行后默认是按住圆盘键出现射线,松开消失,大家可以自定义
2丶射线的监听事件
(1)在场景中创建一个Cube用来触发射线检测用,位于相机前方([VRTK_SDKManager]的Z轴方向)
(2)在Right上新建脚本SimplePointerEvents,通过得到VRTK_DestinationMarker组件注册方法,就可以监听射线的触发了
注意:VRTK_Pointer组件是继承于VRTK_DestinationMarker组件
using UnityEngine; using VRTK;// 引用VRTK命名空间 public class SimplePointerEvents : MonoBehaviour { private VRTK_DestinationMarker destinationMarker; private void Awake() { destinationMarker = GetComponent<VRTK_DestinationMarker>(); destinationMarker.DestinationMarkerEnter += DestinationMarker_DestinationMarkerEnter; destinationMarker.DestinationMarkerExit += DestinationMarker_DestinationMarkerExit; destinationMarker.DestinationMarkerHover += DestinationMarker_DestinationMarkerHover; destinationMarker.DestinationMarkerSet += DestinationMarker_DestinationMarkerSet; } private void DestinationMarker_DestinationMarkerSet(object sender, DestinationMarkerEventArgs e) { Debug.Log("与物体交互"); } private void DestinationMarker_DestinationMarkerHover(object sender, DestinationMarkerEventArgs e) { Debug.Log("射线悬停物体"); } private void DestinationMarker_DestinationMarkerExit(object sender, DestinationMarkerEventArgs e) { Debug.Log("射线退出物体"); } private void DestinationMarker_DestinationMarkerEnter(object sender, DestinationMarkerEventArgs e) { Debug.Log("射线进入物体"); } }
以上是关于VRTK3.3.0-003发出一条简单射线和监听的主要内容,如果未能解决你的问题,请参考以下文章
2019杭电多校第⑨场B Rikka with Cake (主席树,离散化)
POJ 3182 The Grove [DP(spfa) 射线法]