Unity3d【坦克大战图文教学3】创建GUI场景切换菜单
本帖最后由 神秘入侵者 于 2012-12-19 15:28 编辑本节为:【坦克3】创建GUI场景切换菜单
private var menuShow:boolean;
function Start()
{
DontDestroyOnLoad(this);
menuShow=true;
}
function Update () {
if(Input.GetKeyDown(KeyCode.Escape))
{
menuShow=true;
}
}
function OnGUI()
{
if(menuShow==false)
{
return;
}
if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2-50,60,30),"Level1"))
{
print("You Click The Button Level1");
Application.LoadLevel(0);
menuShow=false;
}
else if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2-10,60,30),"Level2"))
{
print("You Click The Button Level2");
Application.LoadLevel(1);
menuShow=false;
}
else if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2+30,60,30),"Level3"))
{
print("You Click The Button Level3");
Application.LoadLevel(2);
menuShow=false;
}
else if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2+70,60,30),"Quit"))
{
print("You Click The Quit Button!");
Application.Quit();
menuShow=false;
}
}放在menu在场景中即可,然后调用其他场景,按ESC返回menu菜单。
场景的INDEX值在FILE->Building Setting中,选择当前场景,然后点add current即可
感谢论坛提供的资源{:soso_e154:} 楼主太有才了,膜拜中…… 楼主属于高手,这里学习参考楼主的成果。
膜拜中。。。。{:soso__7524161091986203637_5:} 感谢楼主无私奉献 楼主是超人 顶顶多好 很好哦 不错不错 LZ真是人才