Rect.Contains Manual     Reference     Scripting  
Scripting > Runtime Classes > Rect
Rect.Contains

function Contains (point : Vector2) : bool

function Contains (point : Vector3) : bool

Description

Returns true if the x and y components of point is a point inside this rectangle.

JavaScripts
// prints inside when mouse is in lower left corner

function Update () {
var rect = Rect (0, 0, 150, 150);
if (rect.Contains(Input.mousePosition))
print("Inside");
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Update() {
Rect rect = new Rect(0, 0, 150, 150);
if (rect.Contains(Input.mousePosition))
print("Inside");

}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Update():
rect as Rect = Rect(0, 0, 150, 150)
if rect.Contains(Input.mousePosition):
print('Inside')