12345678910111213141516171819202122232425 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class RaycasHitManager : MonoBehaviour
- {
- // Start is called before the first frame update
- void Start()
- {
-
- }
- // Update is called once per frame
- void Update()
- {
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- Debug.DrawRay(ray.origin, ray.direction, Color.red);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, int.MaxValue, 1 << LayerMask.NameToLayer("layername")))
- {
- Debug.Log("检测到物体");
- }
- }
- }
|