Version: 2020.2
言語: 日本語
public bool Contains (Vector2 point);
public bool Contains (Vector3 point);
public bool Contains (Vector3 point, bool allowInverse);

パラメーター

point 判定する点
allowInverse Rect の 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"); } }