鼠标抓取gameobject(类似碰撞检测)

2013/06/10 10:56
阅读数 129

using UnityEngine;
using System.Collections;

public class Mouse : MonoBehaviour
{
    Ray ray;
    RaycastHit hit;
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
                Debug.Log(hit.collider.gameObject.name);
        }
    }
}

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部