最终效果:

一、选择背景图片,选择GUI Texture

二、创建一个空的GameObject,然后添加背景音乐

三、创建GUISkin

四、主要代码

#pragma strict

var myGUI:GUISkin;

private var isSound1Button:boolean=false;
private var isSound2Button:boolean=true;
private var sound:AudioSource; function Start () {
sound=gameObject.GetComponent(AudioSource);//方法2创建的空GameObject 里面查找背景音乐
} function Update () { } function OnGUI(){ GUI.skin=myGUI;//通过前端把New GUISkin 赋值给mySkin if(GUI.Button(Rect(390,250,220,66),"",GUI.skin.GetStyle("PlayButton"))){
Application.LoadLevel(1);//或者 Application.LoadLevel("level1"); 此时一定要把场景1添加到BuildSetting中
}
if(GUI.Button(Rect(350,330,320,66),"",GUI.skin.GetStyle("MoreButton"))){ }
if(GUI.Button(Rect(390,400,180,66),"",GUI.skin.GetStyle("CreditButton"))){ } //默认是播放背景音乐
if(isSound1Button){
if(GUI.Button(Rect(30,500,37,30),"",GUI.skin.GetStyle("Sound1Button"))){
audio.Play();
isSound1Button=false;
isSound2Button=true;
}
}
if(isSound2Button){
if(GUI.Button(Rect(30,500,47,30),"",GUI.skin.GetStyle("Sound2Button"))){
audio.Stop();
isSound1Button=true;
isSound2Button=false;
}
} }

from 龚老师视频

最新文章

  1. java面试题——集合框架
  2. 【linux】free命令中cached和buffers的区别
  3. Hdu 2845 Beans
  4. Yii的学习(1)--安装配置
  5. PHP-- 获取http请求头信息
  6. 深入浅出Symfony2 - 如何提高网站响应速度 [转]
  7. linux编译安装MySQL
  8. Node基础:域名解析DNS(ok)
  9. ReactiveCocoa入门教程:第一部分
  10. iOS 和 Android 中的Alert
  11. 5、第5节课CSS补充和html 标签讲解20150924
  12. DataTables语言国际化
  13. Windows编译安装mod_wsgi,配合使用Django+Apahce
  14. linux 驱动入门1
  15. Python3 File 方法
  16. VUE v-for问题
  17. Pandas库中的DataFrame
  18. 第三组 通信一班 030 OSPFv2、OSPFv3综合实验
  19. C风格字符串和C++string对象的相互转化
  20. [原创]SpotLight性能监控工具使用介绍

热门文章

  1. Grunt--Less
  2. 修复日志,阻止给日志多次添加handlers时候重复打印的问题
  3. c++静态全局,局部变量---18
  4. [Model] LeNet-5 by Keras
  5. Python 统计代码量
  6. yii 前端js动态添加验证规则
  7. Android5.x新特性之 Toolbar和Theme的使用
  8. codeforces水题100道 第八题 Codeforces Round #274 (Div. 2) A. Expression (math)
  9. QT——信号槽
  10. 【docker】 VI/VIM 无法使用系统剪贴板(clipboard)