Version: 2017.2
public static void DrawTexture (Rect screenRect, Texture texture, Material mat= null, int pass= -1);
public static void DrawTexture (Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat= null, int pass= -1);
public static void DrawTexture (Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat= null, int pass= -1);
public static void DrawTexture (Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color, Material mat= null, int pass= -1);

Parámetros

screenRect Rectangle on the screen to use for the texture. In pixel coordinates with (0,0) in the upper-left corner.
texture Texture to draw.
sourceRect Region of the texture to use. In normalized coordinates with (0,0) in the bottom-left corner.
leftBorder Número de píxeles de la izquierda que no están afectados por la escala.
rightBorder Número de píxeles de la derecha que no están afectados por la escala.
topBorder Número de píxeles de arriba que no están afectados por la escala.
bottomBorder Número de píxeles de abajo que no están afectados por la escala.
color Color that modulates the output. The neutral value is (0.5, 0.5, 0.5, 0.5). Set as vertex color for the shader.
mat Custom Material that can be used to draw the texture. If null is passed, a default material with the Internal-GUITexture.shader is used.
pass If -1 (default), draws all passes in the material. Otherwise, draws given pass only.

Descripción

Draw a texture in screen coordinates.

If you want to draw a texture from inside of OnGUI code, you should only do that from EventType.Repaint events. It's probably better to use GUI.DrawTexture for GUI code.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Texture aTexture; void OnGUI() { if (Event.current.type.Equals(EventType.Repaint)) Graphics.DrawTexture(new Rect(10, 10, 100, 100), aTexture); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961