Version: 2019.4
public bool Contains (Vector2 point);
public bool Contains (Vector3 point);
public bool Contains (Vector3 point, bool allowInverse);

パラメーター

point判定する点
allowInverseRect の width と height が負の値でも許可するかどうか

戻り値

bool ポイントが矩形内にあれば True を返します。

説明

XYpoint が Rect 内にある場合は true を返します もし allowInverse が true の場合、Rect の width と height が負の値でも動作するようになります(例えば最小値が最大値を超えてしまう場合)。

using UnityEngine;

public class RectExample : MonoBehaviour { void Update() { Rect rect = new Rect(0, 0, 150, 150); if (rect.Contains(Input.mousePosition)) Debug.Log("Inside"); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961