Unity3D常用脚本.doc

Unity3D常用脚本.doc

ID:49706967

大小:2.80 MB

页数:16页

时间:2020-03-03

Unity3D常用脚本.doc_第1页
Unity3D常用脚本.doc_第2页
Unity3D常用脚本.doc_第3页
Unity3D常用脚本.doc_第4页
Unity3D常用脚本.doc_第5页
资源描述:

《Unity3D常用脚本.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、.场景转换:varscreenbutton:boolean;functionStart(){DontDestroyOnLoad(this);screenbutton=true;}functionUpdate(){if(Input.GetKeyDown(KeyCode.Escape)){screenbutton=true;}}functionOnGUI(){if(screenbutton==true)if(GUI.Button(Rect(Screen.width/2-380,Screen.height/

2、2-190,60,50),"Scene1")){print("YouclickScene1");Application.LoadLevel(1);screenbutton=false;}elseif(GUI.Button(Rect(Screen.width/2-380,Screen.height/2-130,60,50),"Scene2")){print("YouclickScene2");Application.LoadLevel(2);screenbutton=false;}elseif(GUI.

3、Button(Rect(Screen.width/2-375,Screen.height/2-0,50,50),"Quit")){print("YouclickQuit");Application.Quit();}}心得:场景转换时,这个程序贴在按钮界面场景中。在BuildSetting(导出)(在File下)菜单中加入所需场景。Word资料.0为按钮界面。可以无限增加场景。}elseif(GUI.Button(Rect(Screen.width/2-380,Screen.height/2-130,6

4、0,50),"Scene2")){print("YouclickScene2");Application.LoadLevel(2);screenbutton=false;复制此段程序并做修改。运动控制键:上下左右varTankSpeed:int=20;functionUpdate(){if(Input.GetKey(KeyCode.W)){print("go");transform.Translate(Vector3.forward*Time.deltaTime*TankSpeed);}elseif(

5、Input.GetKey(KeyCode.S)){print("goback");transform.Translate(Vector3.forward*Time.deltaTime*-TankSpeed);}elseif(Input.GetKey(KeyCode.A)){print("turnleft");transform.Rotate(Vector3.up*Time.deltaTime*-TankSpeed);}elseif(Input.GetKey(KeyCode.D)){print("tur

6、nright");Word资料.transform.Rotate(Vector3.up*Time.deltaTime*TankSpeed);}}需要放在第一视角的物体或者摄像机上。加天空背景:菜单栏Component下的Rendering下的Skybox。将他加在所需场景的摄像机上,选择所需的天空。运行时自然出现。各种按钮汇总:Word资料.鼠标碰触后显示说明文字。functionOnGUI(){GUI.Button(Rect(0,0,100,20),GUIContent("Clickme","Thi

7、sisthetooltip"));GUI.Label(Rect(0,40,100,40),GUI.tooltip);}多项选择,以上都选择。varallOptions=true;varextended1=true;varextended2=true;functionOnGUI(){allOptions=GUI.Toggle(Rect(0,120,150,20),allOptions,"EditAllOptions");GUI.enabled=allOptions;extended1=GUI.Toggl

8、e(Rect(20,70,130,20),extended1,"ExtendedOption1");extended2=GUI.Toggle(Rect(20,90,130,20),extended2,"ExtendedOption2");Word资料.GUI.enabled=true;if(GUI.Button(Rect(0,160,150,20),"Ok"));print("userclickedok");}鼠标碰触第一个按钮有解释,鼠标碰触第三个对话

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。