Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

Graphics.DrawTexture

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public static function DrawTexture(screenRect: Rect, texture: Texture, mat: Material = null): void;
public static void DrawTexture(Rect screenRect, Texture texture, Material mat = null);
public static function DrawTexture(screenRect: Rect, texture: Texture, leftBorder: int, rightBorder: int, topBorder: int, bottomBorder: int, mat: Material = null): void;
public static void DrawTexture(Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat = null);
public static function DrawTexture(screenRect: Rect, texture: Texture, sourceRect: Rect, leftBorder: int, rightBorder: int, topBorder: int, bottomBorder: int, mat: Material = null): void;
public static void DrawTexture(Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat = null);
public static function DrawTexture(screenRect: Rect, texture: Texture, sourceRect: Rect, leftBorder: int, rightBorder: int, topBorder: int, bottomBorder: int, color: Color, mat: Material = null): void;
public static void DrawTexture(Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color, Material mat = null);

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 Number of pixels from the left that are not affected by scale.
rightBorder Number of pixels from the right that are not affected by scale.
topBorder Number of pixels from the top that are not affected by scale.
bottomBorder Number of pixels from the bottom that are not affected by scale.
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.

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.

	// Draws a texture on the screen at 10, 10 with 100 width, 100 height.

var aTexture : Texture;

function OnGUI() { if(Event.current.type.Equals(EventType.Repaint)) Graphics.DrawTexture(Rect(10, 10, 100, 100), aTexture); }
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); } }