static function DrawTexture (position : Rect, image : Texture, scaleMode : ScaleMode = ScaleMode.StretchToFill, alphaBlend : boolean = true, imageAspect : float = 0) : void
Parameters
| Name | Description |
| position |
Rectangle on the screen to draw the texture within.
|
| image |
Texture to display.
|
| scaleMode |
How to scale the image when the aspect ratio of it doesn't fit the aspect ratio to be drawn within.
|
| alphaBlend |
Whether to alpha blend the image on to the display (the default). If false, the picture is drawn on to the display.
|
| imageAspect |
Aspect 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.
See Also: GUI.color, GUI.contentColor
var aTexture : Texture;
function OnGUI() {
if(!aTexture){
Debug.LogError("Assign a Texture in the inspector.");
return;
}
GUI.DrawTexture(Rect(10,10,60,60), aTexture, ScaleMode.ScaleToFit, true, 10.0f);
}
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Texture aTexture;
void OnGUI() {
if (!aTexture) {
Debug.LogError("Assign a Texture in the inspector.");
return;
}
GUI.DrawTexture(new Rect(10, 10, 60, 60), aTexture, ScaleMode.ScaleToFit, true, 10.0F);
}
}
import UnityEngine
import System.Collections
class example(MonoBehaviour):
public aTexture as Texture
def OnGUI():
if not aTexture:
Debug.LogError('Assign a Texture in the inspector.')
return
GUI.DrawTexture(Rect(10, 10, 60, 60), aTexture, ScaleMode.ScaleToFit, true, 10.0F)