unity3d 怎样获得当前鼠标点击的对象

最佳答案
 
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
var target: GameObject = hit.collider.gameObject//获得点击的物体
if(Input.getMouseButtonDown("0"))
{
target.transform.position = (Input.mousePosition);
}
} 先获取鼠标坐标然后再发射射线检测
05-08 15:03