您的位置:首页 > 其它

VR开发中HTC手柄发射射线的控制

2017-05-02 17:44 417 查看
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 手柄发射射线的控制
/// </summary>
public class LineEvents : MonoBehaviour {
//new 一个对象
SteamVR_LaserPointer laserPointer;
// Use this for initialization
void Start () {
laserPointer = GetComponent<SteamVR_LaserPointer>();
//响应射线碰到的事件
laserPointer.PointerIn += OnPointerIn;
//响应射线离开的事件
laserPointer.PointerOut += OnPointerOut;
}
// Update is called once per frame
void Update () {

}
//射线碰到
void OnPointerIn(object sender, PointerEventArgs e)
{
//射线指向东西的名字
print(e.target.gameObject.name);
}
//射线离开
void OnPointerOut(object sender, PointerEventArgs e)
{
print("射线离开了");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  htc