语言中文
  • C#

RaycastHit.collider

public 碰撞器 碰撞器;

说明

命中的 碰撞器

如果光线未命中任何物体,则此属性为 null,如果命中了碰撞器,则不为 null。

using UnityEngine;

public class Example : MonoBehaviour { void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

if (Physics.Raycast(ray, out hit)) { if (hit.collider != null) { hit.collider.enabled = false; } } } } }

Did you find this page useful? Please give it a rating: