Bounds.IntersectRay

Switch to Manual
public bool IntersectRay (Ray ray);

Description

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);

Description

ray 是否与该包围盒交叠?

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