ray
是否与该包围盒相交?
using UnityEngine;
public class Example : MonoBehaviour { // Function to detect if a ray (representing a beam weapon, say) // makes contact with the collider's bounds.
Collider myCollider;
void Start() { // Store a reference to the collider once at startup. myCollider = GetComponent<Collider>(); }
bool DetectHit(Ray ray) { return myCollider.bounds.IntersectRay(ray); } }
ray
是否与该包围盒相交?
当函数返回 true 时,到射线原点的距离将返回到 distance
参数中。