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.
如果point的x和y组件是这个矩形里面的点,返回真。
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");
}
}
// prints inside when mouse is in lower left corner
//当鼠标移到左下角时,打印"在里面"
function Update () {
var rect = Rect (0, 0, 150, 150);
if (rect.Contains(Input.mousePosition))
print("在里面");
}
最后修改:2010年12月21日 Tuesday 16:18