LanguageEnglish
  • C#
  • JS

Script language

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

This version of Unity is unsupported.

GUI.DrawTexture

public static method DrawTexture(position: Rect, image: Texture): void;
public static method DrawTexture(position: Rect, image: Texture, scaleMode: ScaleMode): void;
public static method DrawTexture(position: Rect, image: Texture, scaleMode: ScaleMode, alphaBlend: bool): void;
public static method DrawTexture(position: Rect, image: Texture, scaleMode: ScaleMode, alphaBlend: bool, imageAspect: float): void;

Parameters

positionRectangle on the screen to draw the texture within.
image Texture to display.
scaleModeHow to scale the image when the aspect ratio of it doesn't fit the aspect ratio to be drawn within.
alphaBlendWhether to apply alpha blending when drawing the image (enabled by default).
imageAspectAspect ratio to use for the source image. If 0 (the default), the aspect ratio from the image is used. Pass in w/h for the desired aspect ratio. This allows the aspect ratio of the source image to be adjusted without changing the pixel width and height.

Description

Draw a texture within a rectangle.

no example available in JavaScript

public static method DrawTexture(position: Rect, image: Texture, scaleMode: ScaleMode, alphaBlend: bool, imageAspect: float, color: Color, borderWidth: float, borderRadius: float): void;
public static method DrawTexture(position: Rect, image: Texture, scaleMode: ScaleMode, alphaBlend: bool, imageAspect: float, color: Color, borderWidths: Vector4, borderRadius: float): void;

Parameters

positionRectangle on the screen to draw the texture within.
image Texture to display.
scaleModeHow to scale the image when the aspect ratio of it doesn't fit the aspect ratio to be drawn within.
alphaBlendWhether to apply alpha blending when drawing the image (enabled by default).
imageAspectAspect ratio to use for the source image. If 0 (the default), the aspect ratio from the image is used. Pass in w/h for the desired aspect ratio. This allows the aspect ratio of the source image to be adjusted without changing the pixel width and height.
colorA tint color to apply on the texture.
borderWidthThe width of the border. If 0, the full texture is drawn.
borderWidthsThe width of the borders (left, top, right and bottom). If Vector4.zero, the full texture is drawn.
borderRadiusThe radius for rounded corners. If 0, corners will not be rounded.
borderRadiusesThe radiuses for rounded corners (top-left, top-right, bottom-right and bottom-left). If Vector4.zero, corners will not be rounded.

Description

Draws a border with rounded corners within a rectangle. The texture is used to pattern the border. Note that this method only works on shader model 2.5 and above.