0
UI에서 Cardboard Gaze 스크립트를 사용하려고합니다. 이 스크립트는 카메라에 첨부되어 있으며 UI 항목은 ICardboardResponder를 성공적으로 구현하고 있습니다.Unity VR 마분지가 UI에서 작동하지 않습니다.
UI에서 Cardboard Gaze 스크립트를 사용하려고합니다. 이 스크립트는 카메라에 첨부되어 있으며 UI 항목은 ICardboardResponder를 성공적으로 구현하고 있습니다.Unity VR 마분지가 UI에서 작동하지 않습니다.
이 스크립트를 시도
void FixedUpdate() {
var pointerEventData = new PointerEventData(EventSystem);
Vector2 hotspot = new Vector2(0.5f, 0.5f);
if(UnityEngine.VR.VRSettings.enabled)
pointerEventData.position = new Vector2(hotspot.x * UnityEngine.VR.VRSettings.eyeTextureWidth, hotspot.y * UnityEngine.VR.VRSettings.eyeTextureHeight);
else
pointerEventData.position = new Vector2(hotspot.x * Screen.width, hotspot.y * Screen.height);
List<RaycastResult> raycastResults = new List<RaycastResult>();
EventSystem.RaycastAll(pointerEventData, raycastResults);
for (var i = 0; i < raycastResults.Count; i++)
{
var hit = raycastResults[i];
var other = hit.gameObject;
var cardboardResponder = other.GetComponent<ICardboardResponder>()
if (cardboardResponder != null)
{
//Do domething
}
}
}