手柄上需挂载VRTK_Pointer脚本(主要依托的是VRTK_DestinationMarker)
public class Test: MonoBehaviour {
VRTK_Pointer point;
private void Start()
{
point =this.GetComponent<VRTK_Pointer>();
point.DestinationMarkerEnter += DoPointerIn;
point.DestinationMarkerExit += DoPointerOut;
point.DestinationMarkerHover += DoPointerHover;
point.DestinationMarkerSet += DoPointerSet;
}
void DoPointerIn(object sender, DestinationMarkerEventArgs e)
{
Debug.Log(e.target.name);//进入时获取物体的名字
}
void DoPointerOut(object sender, DestinationMarkerEventArgs e)
{
}
void DoPointerHover(object sender, DestinationMarkerEventArgs e)
{
}
void DoPointerSet(object sender, DestinationMarkerEventArgs e)
{
}
}
参考VRTK 脚本VRTK_ControllerPointerEvents_ListenerExample