承接ARVR外包项目 史小川QQ: 2118590660
ARVR行业交流QQ群:750656715
公众号: ARVR行业领跑者
B站: ARVRinChina
SteamVR 设置进入UI 直 射线显示, teleporting不显示
出了UI 射线不显示, teleporting显示
我是直接在之前, 封装射线检测信息里面加的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using Valve.VR.Extras;
using Valve.VR;
using Valve.VR.InteractionSystem;
public class SteamVRLaserWrapper : MonoBehaviour
{
private SteamVR_LaserPointer steamVrLaserPointer;
//sxc
private Hand hand;
private void Awake()
{
steamVrLaserPointer = gameObject.GetComponent();
steamVrLaserPointer.PointerIn += OnPointerIn;
steamVrLaserPointer.PointerOut += OnPointerOut;
steamVrLaserPointer.PointerClick += OnPointerClick;
//sxc
steamVrLaserPointer.thickness = 0f;
if (hand == null)
{
hand = this.GetComponent();
}
}
void Update()
{
//TouchPress按下的时候是瞬移射线, 不显示UI直射线
if (SteamVR_Input.GetState("default", "Teleport", hand.handType))
{
Debug.Log("Teleport");
steamVrLaserPointer.thickness = 0f;
}
}
private void OnPointerClick(object sender, PointerEventArgs e)
{
IPointerClickHandler clickHandler = e.target.GetComponent();
if (clickHandler == null)
{
return;
}
clickHandler.OnPointerClick(new PointerEventData(EventSystem.current));
}
private void OnPointerOut(object sender, PointerEventArgs e)
{
//sxc
steamVrLaserPointer.thickness = 0f;
IPointerExitHandler pointerExitHandler = e.target.GetComponent();
if (pointerExitHandler == null)
{
return;
}
pointerExitHandler.OnPointerExit(new PointerEventData(EventSystem.current));
}
private void OnPointerIn(object sender, PointerEventArgs e)
{
//sxc
steamVrLaserPointer.thickness = 0.002f;
IPointerEnterHandler pointerEnterHandler = e.target.GetComponent();
if (pointerEnterHandler == null)
{
return;
}
pointerEnterHandler.OnPointerEnter(new PointerEventData(EventSystem.current));
}
}
原来代码的作用: https://blog.csdn.net/chuan403082010/article/details/95166998