2015-01-11 7 views

답변

-2

이렇게하는 방법은 레이 캐스트를 보내는 것입니다.

if(Input.GetMouseButtonDown(0)) 
{      
    RaycastHit hit = new RaycastHit(); 
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); 

    if(Physics.Raycast(ray, out hit)) 
     print(hit.collider.transform.gameObject.name); 
} 
+2

다음과 같이 표시됩니다. 'List raycastResults = 새 List (); \t \t EventSystem.current.RaycastAll (eventData, raycastResults); ' 감사! – FrakyDale

0

차라리 여기 raycasting 덤비는 것보다 UI 요소 (아마도 포인터 아래로 당신이 원하는 무엇인가?)과의 상호 작용을 검출하는 이벤트 트리거를 사용하십시오.