找回密码
 立即注册
查看: 7100|回复: 111

[实例] Unity3d【坦克大战图文教学3】创建GUI场景切换菜单

[复制链接]
发表于 2012-12-19 15:27 | 显示全部楼层 |阅读模式
资源信息 Tutorial Information
教程名称: Unity3d【坦克大战图文教学3】创建GUI场景切换菜单(发帖教程)
适用引擎:   (适用引擎,为空默认为Unity)
教程语种: 中文
教程等级: 1
教程格式: 图文(请用IE9以上浏览器访问本版块)
教程作者: 原创 (如有问题请短消息联系作者或发表回复)
下载地址: (兑换积分)
点击查看原图
美丽分割线
本帖最后由 神秘入侵者 于 2012-12-19 15:28 编辑


本节为:【坦克3】创建GUI场景切换菜单


  1. private var menuShow:boolean;

  2. function Start()
  3. {   
  4.     DontDestroyOnLoad(this);
  5.     menuShow=true;
  6. }


  7. function Update () {
  8.     if(Input.GetKeyDown(KeyCode.Escape))
  9.     {
  10.         menuShow=true;
  11.     }
  12. }
  13. function OnGUI()
  14. {
  15.    
  16.     if(menuShow==false)
  17.     {
  18.         return;
  19.     }
  20.     if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2-50,60,30),"Level1"))
  21.     {
  22.         print("You Click The Button Level1");
  23.         Application.LoadLevel(0);
  24.         menuShow=false;
  25.     }
  26.     else if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2-10,60,30),"Level2"))
  27.     {
  28.         print("You Click The Button Level2");
  29.         Application.LoadLevel(1);
  30.         menuShow=false;
  31.     }
  32.         else if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2+30,60,30),"Level3"))
  33.     {
  34.         print("You Click The Button Level3");
  35.         Application.LoadLevel(2);
  36.         menuShow=false;
  37.     }
  38.     else if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2+70,60,30),"Quit"))
  39.     {
  40.         print("You Click The Quit Button!");
  41.         Application.Quit();
  42.         menuShow=false;
  43.     }
  44. }
复制代码
放在menu在场景中即可,然后调用其他场景,按ESC返回menu菜单。
场景的INDEX值在FILE->Building Setting中,选择当前场景,然后点add current即可



感谢论坛提供的资源{:soso_e154:}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

厉害!  发表于 2014-1-6 13:55

评分

参与人数 1鲜花 +2 收起 理由
rogerj + 2

查看全部评分

发表于 2013-2-24 08:45 | 显示全部楼层
楼主太有才了,膜拜中……
发表于 2014-1-6 13:53 | 显示全部楼层
楼主属于高手,这里学习参考楼主的成果。
发表于 2014-4-24 20:39 | 显示全部楼层

膜拜中。。。。{:soso__7524161091986203637_5:}
发表于 2014-6-24 17:31 | 显示全部楼层
感谢楼主无私奉献
发表于 2017-5-5 11:46 | 显示全部楼层
楼主是超人
发表于 2017-5-5 11:48 | 显示全部楼层
顶顶多好
发表于 2017-5-5 11:51 | 显示全部楼层
很好哦
发表于 2017-5-5 11:31 | 显示全部楼层
不错不错
发表于 2017-5-5 11:31 | 显示全部楼层
LZ真是人才
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-3-29 00:29 , Processed in 0.107781 second(s), 33 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表