static function DrawTexture (position : Rect, image : Texture, scaleMode : ScaleMode = ScaleMode.StretchToFill, alphaBlend : bool = true, imageAspect : float = 0) : void
Description描述
Draw a texture within a rectangle.
在矩形内绘制一个纹理
另见: GUI.color, GUI.contentColor
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Texture aTexture;
void OnGUI() {
if (!typeof(aTexture)) {
Debug.LogError("Assign a Texture in the inspector.");
return;
}
GUI.DrawTexture(new Rect(10, 10, 60, 60), aTexture, ScaleMode.ScaleToFit, true, 10.0F);
}
}
var aTexture : Texture;
function OnGUI() {
if(!aTexture){
//如果不指定图片会输出这条消息
Debug.LogError("请指定一个纹理图片");
return;
}
//绘制一个60x60像素大小的矩形,添加一个图片将被拉伸匹配这个矩形,并且进行通道混合,图片缩放比例为10:1
GUI.DrawTexture(Rect(10,10,60,60), aTexture, ScaleMode.ScaleToFit, true, 10.0f);
}