Version: 2017.1

Bounds.IntersectRay

切换到手册
public bool IntersectRay (Ray ray);

描述

ray 是否与该包围盒交叠?

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Collider coll; void Start() { coll = GetComponent<Collider>(); } bool DetectHit(Ray ray) { return coll.bounds.IntersectRay(ray); } }

public bool IntersectRay (Ray ray, out float distance);

描述

ray 是否与该包围盒交叠?

当此函数返回 true 时,将在 distance 参数中返回到该光线原点的距离。