标签:col 检测 arp ast 点击 csharp new null cas
2D:
Vector2 mousePoint2D = new Vector2(Input.mousePosition.x, Input.mousePosition.y); RaycastHit2D hitInfo2D = Physics2D.Raycast(mousePoint2D, Vector2.zero); if (hitInfo2D.collider != null) { Debug.Log(hitInfo2D.collider.name); //点击到的物体 }
3D:
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo)) { //点击到物体 }
标签:col 检测 arp ast 点击 csharp new null cas
原文地址:http://www.cnblogs.com/lichuangblog/p/8011394.html