| point | 要测试的点。 |
| allowInverse | 测试是否允许 Rect 的宽度和高度为负值? |
bool 如果点位于指定矩形内,则为 true。
如果 point 的 x 和 y 分量是此矩形内部的点,则返回 true。如果 allowInverse 存在并且为 true,则允许 Rect 的宽度和高度取负值(即,最小值大于最大值),测试仍然有效。
using UnityEngine;
public class RectExample : MonoBehaviour { void Update() { Rect rect = new Rect(0, 0, 150, 150); if (rect.Contains(Input.mousePosition)) Debug.Log("Inside"); } }