📜  光线投射以在统一 2d 游戏中找到对象上的鼠标点击 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:58.201000             🧑  作者: Mango

代码示例1
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

if(hit.collider != null)
{
    Debug.Log ("Target Position: " + hit.collider.gameObject.transform.position);
}