Gizmos.DrawGUITexture

切换到手册
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);

参数

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

描述

在该场景中绘制一个纹理。

所选纹理是在 XY 平面(即,Z 坐标为零的平面)定义的“屏幕”上的 3D 空间中 绘制的。纹理矩形的值是以场景单位 给出的。可选边框值以场景单位指定从该矩形内的每条边缘嵌入; 在嵌入的矩形内绘制该纹理,并且向外重复边缘像素。当围绕主纹理的大型 背景区域的边缘为单色时,这是创建此区域的一种非常有用的快速方式。

在结合直接指向该纹理的摄像机创建 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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961