Unity 3D学习日记(3)
来源:互联网 发布:人参出口韩国数据 编辑:程序博客网 时间:2024/05/29 08:30
Day3
1.int x=0;
if(Input.GetButtonDown(“Fire1”)){
x=x+1;
}
2.访问物体以及物体的组件
gameObject.Find(“NOB”).GetComponent(GUIText)=”子弹数”+x;
C#版:GameObject.Find (“Canvas/NOB”).GetComponent().text = “Number of bullet: ” + i;
3.实现消灭计数 int NOD=0
if(GameObject.transform.position.y<0){
GameObject.Find(“Main Camera”).GetComponent().NOD++;
}
4.GameObject.Find().GetCompnent<>().enable=false;
5.添加按钮 屏幕左上角是(0,0),(x,y,长,宽)
void OnGUI()
if(GUI.Button(Rect(180,100,60,30),”Quit”)){
Application.Quit();
}
if(GUI.Button(Rect(280,100,60,30),”Restart”)){
Application.LoadLevel(“01”);//重新加载场景
}
gameObject.GetCompnent().Play();
audio.Pause();
audio.Stop();
6.添加声音 添加Audio Source
Play On Awake自动播放
Loop 循环播放
void OnGUI(){ //Quit and Restart game if(GUI.Button(new Rect(0,100,60,30),"Quit")){ Application.Quit(); } if(GUI.Button(new Rect(60,100,60,30),"Restart")){ Application.LoadLevel("01"); } if(GUI.Button(new Rect(100,130,70,50),"Play")){ gameObject.GetComponent<AudioSource> ().Play(); } if (GUI.Button (new Rect (100, 200, 70, 50), "Pause")) { gameObject.GetComponent<AudioSource> ().Pause(); } if (GUI.Button (new Rect (100, 270, 70, 50), "Stop")) { gameObject.GetComponent<AudioSource> ().Stop(); } }
阅读全文
0 0
- Unity 3D学习日记(3)
- Unity 3D学习日记(1)
- Unity 3D学习日记(2)
- Unity 3D学习日记(4)
- Unity 3D学习日记(5)
- Unity 3D学习日记(6)
- unity 3D学习
- unity 3D 学习
- unity学习日记:怎样在UI界面上渲染3D模型
- unity 3D学习日记:创建一个小场景并编写简单C#移动脚本
- Unity 3D 学习笔记(1)
- Unity 3D 学习笔记
- Unity 3D 学习笔记
- Unity 3D 学习笔记
- Unity 3D 学习笔记
- Unity 3D 学习笔记
- Unity 3D学习笔记
- Unity 3D学习习题
- 最小子数组
- 比较详细的讲01背包问题(值得看)
- AutoCompleteTextView
- 第二周项目三:体验复杂度
- JDBC调用存储过程
- Unity 3D学习日记(3)
- POJ2632 Crashing Robots(模拟)
- 一步一步写MP3项目的Makefile--自动添加目标对头文件的依赖
- js中的prototype的用法
- Spring AOP
- STM32用串口(USB串口)下载程序的方法
- java 子类继承父类运行顺序
- 网络经济与企业管理
- Scala Option(选项)