2016-11-30 3 views

답변

0

이 스크립트를 시도

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 
     } 
    } 
} 
관련 문제