Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Gizmos.DrawGUITexture

static function DrawGUITexture(screenRect: Rect, texture: Texture, mat: Material = null): void;
static void DrawGUITexture(Rect screenRect, Texture texture, Material mat = null);
static def DrawGUITexture(screenRect as Rect, texture as Texture, mat as Material = null) as void
static function DrawGUITexture(screenRect: Rect, texture: Texture, leftBorder: int, rightBorder: int, topBorder: int, bottomBorder: int, mat: Material = null): void;
static void DrawGUITexture(Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat = null);
static def DrawGUITexture(screenRect as Rect, texture as Texture, leftBorder as int, rightBorder as int, topBorder as int, bottomBorder as int, mat as Material = null) as void

Parameters

screenRectThe size and position of the texture on the "screen" defined by the XY plane.
textureThe texture to be displayed.
matAn optional material to apply the texture.
leftBorderInset from the rectangle's left edge.
rightBorderInset from the rectangle's right edge.
topBorderInset from the rectangle's top edge.
bottomBorderInset from the rectangle's bottom edge.

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.

This function can be useful for creating GUI backgrounds in conjunction with a camera pointing directly at the texture.

	var myTexture : Texture;

function OnDrawGizmos () { Gizmos.DrawGUITexture(Rect(10, 10, 20, 20), myTexture); }