你的位置:首页 > Java教程

[Java教程]Unity3D之2D文理Moive文理使用


#pragma strict

private var oneTexture:Texture2D;
private var allTexture:Object[];

function OnGUI()
{
if(GUI.Button(Rect(0,20,100,60),"loadOneTexture"))
{
if(oneTexture==null)
{
oneTexture=Resources.Load("oneTexture/Grass");
}
}
if(GUI.Button(Rect(0,140,100,60),"loadAllTexture"))
{
if(allTexture==null)
{
allTexture=Resources.LoadAll("allTextere");
}
}

if(oneTexture!=null)
{
GUI.DrawTexture(Rect(0,20,120,120),oneTexture,ScaleMode.StretchToFill,true,0);
}

if(allTexture!=null)
{
for(var i=0;i<allTexture.Length;i++)
{
GUI.DrawTexture(Rect(0+i*20,120,120,120),allTexture[i],ScaleMode.StretchToFill,true,0);
}
}
}