unity label和图片 gui

时间:2022-09-11 14:40:31
#pragma strict

var str:String;
//接收外部复制贴图
var imageTexture:Texture;
private var imageWidth:int;
private var imageHeight:int;
private var screenWidth:int;
private var screenHeight:int; function Start () { //得到屏幕宽高
screenWidth=Screen.width;
screenHeight=Screen.height; //得到图片宽高
imageWidth=imageTexture.width;
imageHeight=imageTexture.height;
} function Update () { } function OnGUI()
{
//见文字内容显示在屏幕中
GUI.Label(Rect(100,10,100,30),str);
GUI.Label(Rect(100,40,400,30),"当前屏幕宽:"+screenWidth);
GUI.Label(Rect(100,80,100,30),"当前屏幕高:"+screenHeight); GUI.Label(Rect(100,120,imageWidth,imageHeight),imageTexture); }