GUIElement.GetScreenRect 获取屏幕矩形

function GetScreenRect (camera : Camera = null) : Rect

Description描述

Returns bounding rectangle of GUIElement in screen coordinates.

返回在屏幕坐标GUIElement的包围矩形。

If no camera is given a camera filling the entire game window will be assumed.

如果没有指定摄像机,将假定一个摄像机填充整个游戏窗口。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Start() {
		Rect r = guiTexture.GetScreenRect();
		Debug.Log("This gui element is " + r.width + " pixel wide.");
	}
}
function Start () {
	var r : Rect = guiTexture.GetScreenRect ();
	Debug.Log("This gui element is " + r.width + " pixel wide.");
}
Page last updated: 2010-12-24