GUI.DrawTexturestatic function DrawTexture (position : Rect, image : Texture, scaleMode : ScaleMode = ScaleMode.StretchToFill, alphaBlend : boolean = true, imageAspect : float = 0) : voidParameters
DescriptionDraw a texture within a rectangle. See Also: GUI.color, GUI.contentColor
JavaScripts
// Draws a texture in the left corner of the screen.
// The texture is drawn in a window 60x60 pixels. // The source texture is given an aspect ratio of 10x1 // and scaled to fit in the 60x60 rectangle. Because // the aspect ratio is preserved, the texture will fit // inside a 60x10 pixel area of the screen rectangle. 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)
|
