GUITexture.pixelInset 像素嵌入

var pixelInset : Rect

Description描述

Pixel inset used for pixel adjustments for size and position.

像素嵌入用于像素调整大小和位置。

You can set the transform.localScale to Vector3.zero in order to make the GUI texture always the same pixel size.

为了使GUI的纹理总是相同的像素大小,你可以设置transform.localScale到Vector3.zero

GUITexture继承自object 基类,因此不同于一般GUI对象,他具备有Object的属性

关于pixelInset控制在屏幕位置注意:

GUITexture.pixelInset = Rect (x, y, width, height); 此变量用于划定GUITexture的位置及宽高,Rect中x,y的值都为0的时候,所在的位置居于屏幕中心,即的坐标中心是以屏幕中心为(0,0)坐标,它的正负情况符合二维坐标系的四个象限。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		transform.position = Vector3.zero;
		transform.localScale = Vector3.zero;
		guiTexture.pixelInset = new Rect(50, 50, 100, 100);
	}
}
transform.position = Vector3.zero;
transform.localScale = Vector3.zero;
guiTexture.pixelInset = Rect (50, 50, 100, 100); 
Page last updated: 2011-1-24