screenRect | XY 平面定义的“屏幕”上纹理的大小和位置。 |
texture | 要显示的纹理。 |
mat | 将应用此纹理的可选材质。 |
leftBorder | 从该矩形的左边缘嵌入。 |
rightBorder | 从该矩形的右边缘嵌入。 |
topBorder | 从该矩形的顶边缘嵌入。 |
bottomBorder | 从该矩形的底边缘嵌入。 |
Draw a texture in the Scene.
The chosen texture is drawn in 3D space on a "screen" defined by the XY plane (ie,
the plane where the Z coordinate is zero). The values of the texture rectangle are given in Scene
units. The optional border values specify an inset from each edge within the rectangle in Scene units; the texture
is drawn inside the inset rectangle and the edge pixels are repeated outwards. This is a useful quick way
to create a large background region around the main texture when its edges are of a single colour.
在结合直接指向该纹理的摄像机创建 GUI 背景时,
此函数会非常有用。
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public Texture myTexture;
void OnDrawGizmosSelected() { // Draw a semitransparent blue cube at the transforms position Gizmos.DrawGUITexture(new Rect(10, 10, 20, 20), myTexture); } }