Gizmos.DrawGUITexture

Switch to Manual
public static void DrawGUITexture (Rect screenRect, Texture texture, Material mat= null);
public static void DrawGUITexture (Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat= null);

Parameters

screenRectXY 平面定义的“屏幕”上纹理的大小和位置。
texture要显示的纹理。
mat将应用此纹理的可选材质。
leftBorder从该矩形的左边缘嵌入。
rightBorder从该矩形的右边缘嵌入。
topBorder从该矩形的顶边缘嵌入。
bottomBorder从该矩形的底边缘嵌入。

Description

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); } }