ImageVerifierCode 换一换
格式:DOC , 页数:16 ,大小:2.80MB ,
资源ID:3112491      下载积分:8 金币
验证码下载
登录下载
邮箱/手机:
图形码:
验证码: 获取验证码
温馨提示:
支付成功后,系统会自动生成账号(用户名为邮箱或者手机号,密码是验证码),方便下次登录下载和查询订单;
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/3112491.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请。


权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4009-655-100;投诉/维权电话:18658249818。

注意事项

本文(Unity3D常用脚本.doc)为本站上传会员【丰****】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

Unity3D常用脚本.doc

1、 场景转换: var screenbutton: boolean; function Start(){ DontDestroyOnLoad(this); screenbutton = true; } function Update () { if(Input.GetKeyDown(KeyCode.Escape)){ screenbutton = true; } } function OnGUI(){ if(screenbutton==true) if(GUI.Button(Rect(Screen.width/2

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

3、button = false; }else if( GUI.Button(Rect(Screen.width/2-375,Screen.height/2-0,50,50),"Quit")){ print("You click Quit"); Application.Quit(); } } 心得: 场景转换时,这个程序贴在按钮界面场景中。在Build Setting(导出)(在File下)菜单中加入所需场景。 0为按钮界面。可以无限增加场景。 }else if(GUI.Button(Rect(Screen.width/2-380,S

4、creen.height/2-130,60,50),"Scene2")){ print("You click Scene2"); Application.LoadLevel (2); screenbutton = false; 复制此段程序并做修改。 运动控制键:上下左右 var TankSpeed:int = 20; function Update () { if(Input.GetKey(KeyCode.W)){ print("go"); transform.Translate(Vector3.forward

5、 * Time.deltaTime * TankSpeed); }else if(Input.GetKey(KeyCode.S)){ print("go back"); transform.Translate(Vector3.forward * Time.deltaTime * -TankSpeed); }else if(Input.GetKey(KeyCode.A)){ print("turn left"); transform.Rotate(Vector3.up * Time.deltaTime * -TankSpeed); }else

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

7、 100, 20), GUIContent ("Click me", "This is the tooltip")); GUI.Label (Rect (0, 40, 100, 40), GUI.tooltip); } 多项选择,以上都选择。 var allOptions = true; var extended1 = true; var extended2 = true; function OnGUI () { allOptions = GUI.Toggle (Rect (0,120,150,20), allOptions, "Edit All

8、Options"); GUI.enabled = allOptions; extended1 = GUI.Toggle (Rect (20,70,130,20), extended1, "Extended Option 1"); extended2 = GUI.Toggle (Rect (20,90,130,20), extended2, "Extended Option 2"); GUI.enabled = true; if (GUI.Button (Rect (0, 160, 150, 20), "Ok")); print ("user clicked ok"); }

9、 鼠标碰触第一个按钮有解释,鼠标碰触第三个对话框有解释。碰第二个没有解释。 function OnGUI () { GUI.Box (Rect (5, 300, 110, 75), GUIContent ("Box", "This box has a tooltip")); GUI.Button (Rect (10, 230, 100, 20), "No tooltip here"); GUI.Button (Rect (10, 200, 100, 20), GUIContent ("I have a tooltip", "The button overrides the

10、box")); GUI.Label (Rect (10,260,100,40), GUI.tooltip); } 半透明,说明性文字对话框。无选择。 function Update () { } function OnGUI () { GUI.BeginGroup (new Rect (Screen.width / 2 - 400, Screen.height / 2 - 300, 800, 600)); GUI.Box (new Rect (0,0,800,600),"This box is now centered! - here you would put y

11、our main menu"); GUI.EndGroup (); } 滚动条,选择按钮。可以放多个按钮并且节省位置。 function Update () { } var scrollPosition = Vector2.zero; function OnGUI () { scrollPosition = GUI.BeginScrollView (Rect (10,400,100,100), scrollPosition, Rect (0, 0, 220, 200)); GUI.Button (Rect (0,0,100,20), "Top-left"); GU

12、I.Button (Rect (120,0,100,20), "Top-right"); GUI.Button (Rect (0,180,100,20), "Bottom-left"); GUI.Button (Rect (120,180,100,20), "Bottom-right"); GUI.EndScrollView (); } 循环的字幕。 var letterPause = 0.2;//定义每个字出现的时间间隔 var sound : AudioClip;//打字机的声音 private var word;//存储你打字机效果想要输出的字的变量

13、 private var Text : String = "My name is Ray Yang.Keep it in your heart!";//你希望打字机效果输出的字 function Start () { word = Text;//把你输出的字先赋值给word Text = "";//把你要显示的字先抹除,以便你可以在最初显示的时候显示为空,当然你也可以加上其他字,让他先显示,打字机效果打的字会显示在这个后面 yield WaitForSeconds (2); TypeText (); } function OnGUI () { GUI.L

14、abel (Rect(150,15,250,25),"Please answer my question,who am I?"); GUI.Box (Rect(150,40,250,25),Text); } function TypeText () { for (var letter in word.ToCharArray()) {//做一个循环,定义一个变量letter逐次等于word中的每一个字符 Text += letter;//把这些字赋值给Text if (sound)//控制声音,出现一个字,发一个声音 audio.PlayOneShot (so

15、und); yield WaitForSeconds (letterPause); } } function Update () { if(Text == word){ Text=""; TypeText(); } } 有打字声音的字幕循环。 var screnbutton:boolean; var icon : Texture; var allOptions = true; var extended1 = true; var extended2 = true; var letterPause = 0.2;//

16、定义每个字出现的时间间隔 var sound : AudioClip;//打字机的声音 private var word;//存储你打字机效果想要输出的字的变量 static var Text : String = "This is zcx first project! I can do it."; var del : boolean = false; var particle : GameObject; function Start(){ DontDestroyOnLoad(this); screnbutton=true; word = Text; Te

17、xt = ""; yield WaitForSeconds (2); TypeText (); } function Update () { if(Input.GetKeyDown(KeyCode.Escape)){ screnbutton=true;} if( Text == "This is zcx first project! I can do it." ){ Text = ""; TypeText (); } if(Input.GetMouseButtonDown(0)){ Text = ""; for (var c : c

18、har in Input.inputString) { // Backspace - Remove the last character if (c == "\b") { if (guiText.text.Length != 0) guiText.text = guiText.text.Substring(0, guiText.text.Length - 1); } // End of entry else if (c == "\n") { print ("User entered his name: " + guiText.text); } // Normal text

19、input - just append to the end else { guiText.text += c; } } } } function OnGUI(){ if(screnbutton==true){ if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2-30,60,50),"scene1")){ print("you click Scene 1"); Application.LoadLevel (1); screnbutton=false; }else if(GUI.Button(Rect(Scr

20、een.width/2-30,Screen.height/2+30,60,50),"scene2")){ print("you click Scene 2"); Application.LoadLevel (2); screnbutton=false; }else if(GUI.Button(Rect(Screen.width/2-30,Screen.height/2+90,60,50),"scene3")){ print("you click Scene 3"); Application.LoadLevel (3); screnbutton=false; }else if(G

21、UI.Button(Rect(Screen.width/2-30,Screen.height/2+150,60,50),"Quit")){ print("you click Quit"); Application.Quit(); } } //GUI.Button (Rect (0, 0, 100, 20), "Click Me"); GUI.Button (Rect (0, 0, 100, 20), GUIContent ("Click me","This is the tooltip")); GUI.Label (Rect (0, 20, 100, 40), G

22、UI.tooltip); allOptions = GUI.Toggle (Rect (40,40,150,20), allOptions, "Edit All Options"); GUI.enabled = allOptions; extended1 = GUI.Toggle (Rect (60,60,130,20), extended1, "Extended Option 1"); extended2 = GUI.Toggle (Rect (60,80,130,20), extended2, "Extended Option 2"); GUI.enabl

23、ed = true; if (GUI.Button (Rect (40, 100, 150, 20), "Ok")) print ("user clicked ok"); GUI.BeginGroup (new Rect (Screen.width / 2 - 400, Screen.height/2-300,800,600)); GUI.Box (new Rect (0,0,800,600), "This box is now centered!-here you would put your main menu"); GUI.EndGroup ();

24、 GUI.Label (Rect(250,75,250,25),"Please introduce your objec!"); GUI.Box (Rect(250,100,250,25),Text); } function TypeText () { for (var letter in word.ToCharArray()) {//做一个循环,定义一个变量letter逐次等于word中的每一个字符 Text += letter;//把这些字赋值给Text if (sound)//控制声音,出现一个字,发一个声音 audio.P

25、layOneShot (sound); yield WaitForSeconds (letterPause); } } 主板游戏系列程序: CameraMoveRotate(第一视角界面场景自控程序) 使用时点击鼠标右键可以自由转换视角。同时点击AWSD键可以控制前进后退,向左向右。C#程序。 using UnityEngine; using System.Collections; /// MouseLook rotates the transform based on the mouse delta. /// Minimum and Maximu

26、m values can be used to constrain the possible rotation /// To make an FPS style character: /// - Create a capsule. /// - Add a rigid body to the capsule /// - Add the MouseLook script to the capsule. /// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)

27、 /// - Add FPSWalker script to the capsule /// - Create a camera. Make the camera a child of the capsule. Reset it's transform. /// - Add a MouseLook script to the camera. /// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns

28、) [AddComponentMenu("Camera-Control/Mouse Look")] public class CameraMoveRotate : MonoBehaviour { public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 } public RotationAxes axes = RotationAxes.MouseXAndY; public float sensitivityX = 15F; public float sensitivityY = 15F;

29、 public float minimumX = -360F; public float maximumX = 360F; public float minimumY = -60F; public float maximumY = 60F; public float moveSpeed = 5.0F; float rotationX = 0F; float rotationY = 0F; Quaternion originalRotation; void Update () { //鼠标控制的转向 if( !I

30、nput.GetMouseButton(1) ){ return; }else{ if (axes == RotationAxes.MouseXAndY) { // Read the mouse input axis rotationX += Input.GetAxis("Mouse X") * sensitivityX; rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationX = ClampAngle (rotationX, minimumX, m

31、aximumX); rotationY = ClampAngle (rotationY, minimumY, maximumY); Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up); Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, -Vector3.right); transform.localRotation = originalRotation * xQuaternion

32、 * yQuaternion; } else if (axes == RotationAxes.MouseX) { rotationX += Input.GetAxis("Mouse X") * sensitivityX; rotationX = ClampAngle (rotationX, minimumX, maximumX); Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up); transform.localRotation = o

33、riginalRotation * xQuaternion; } else { rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationY = ClampAngle (rotationY, minimumY, maximumY); Quaternion yQuaternion = Quaternion.AngleAxis (-rotationY, Vector3.right); transform.localRotation = originalRotatio

34、n * yQuaternion; } } //键盘控制的运动 float x = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed; float z = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed; transform.Translate(x, 0, z); } void Start () { // Make the rigid body not change rotation

35、 if (rigidbody) rigidbody.freezeRotation = true; originalRotation = transform.localRotation; } public static float ClampAngle (float angle, float min, float max) { if (angle < -360F) angle += 360F; if (angle > 360F) angle -= 360F; return Mathf.Clamp (angle, min, max)

36、 } } Unity3d闪烁灯光脚本 也可以用unity3d做舞厅效果。。把脚本扔给灯光就可以了。 1. using UnityEngine; 2. using System.Collections; 3. [RequireComponent( typeof( Light ) )] 4. public class flickeringLight : MonoBehaviour 5. { 6.     // Flickering Styles 7.     public enum flickerinLightStyles { CampFire = 0, Fluo

37、rescent = 1 }; 8.     public flickerinLightStyles flickeringLightStyle = flickerinLightStyles.CampFire; 9.     // Campfire Methods 10.     public enum campfireMethods { Intensity = 0, Range = 1, Both = 2 }; 11.     public campfireMethods campfireMethod = campfireMethods.Intensity; 12.     // In

38、tensity Styles 13.     public enum campfireIntesityStyles { Sine = 0, Random = 1 }; 14.     public campfireIntesityStyles campfireIntesityStyle = campfireIntesityStyles.Random; 15.     // Range Styles 16.     public enum campfireRangeStyles { Sine = 0, Random = 1 }; 17.     public campfireRange

39、Styles campfireRangeStyle = campfireRangeStyles.Random; 18.     // Base Intensity Value 19.     public float CampfireIntensityBaseValue = 0.5f; 20.     // Intensity Flickering Power 21.     public float CampfireIntensityFlickerValue = 0.1f; 22.     // Base Range Value 23.     public float Camp

40、fireRangeBaseValue = 10.0f; 24.     // Range Flickering Power 25.     public float CampfireRangeFlickerValue = 2.0f; 26.     27.     // If Style is Sine 28.     private float CampfireSineCycleIntensity = 0.0f; 29.     private float CampfireSineCycleRange = 0.0f; 30.     // "Glow" Speeds 31.

41、     public float CampfireSineCycleIntensitySpeed = 5.0f; 32.     public float CampfireSineCycleRangeSpeed = 5.0f; 33.     public float FluorescentFlickerMin = 0.4f; 34.     public float FluorescentFlickerMax = 0.5f; 35.     public float FluorescentFlicerPercent = 0.95f; 36.     // NOT IMPLEMEN

42、TED YET !!!! 37.     public bool FluorescentFlickerPlaySound = false; 38.     public AudioClip FluorescentFlickerAudioClip; 39.     // ------------------------ 40. 41. 42.         // Use this for initialization 43.         void Start () { 44.          45.         } 46.          47.       

43、  // Update is called once per frame 48.         void Update () { 49.         switch( flickeringLightStyle ) 50.         { 51.             // If Flickering Style is Campfire 52.             case flickerinLightStyles.CampFire: 53.                 // If campfire method is Intesity OR Both 54.  

44、               if( campfireMethod == campfireMethods.Intensity || campfireMethod == campfireMethods.Both ) 55.                 { 56.                     // If Intensity style is Sine 57.                     if( campfireIntesityStyle == campfireIntesityStyles.Sine ) 58.                     { 59.

45、                         // Cycle the Campfire angle 60.                         CampfireSineCycleIntensity += CampfireSineCycleIntensitySpeed; 61.                         if( CampfireSineCycleIntensity > 360.0f ) CampfireSineCycleIntensity = 0.0f; 62.                         // Base + Values 63

46、                         light.intensity = CampfireIntensityBaseValue + ( ( Mathf.Sin( CampfireSineCycleIntensity * Mathf.Deg2Rad ) * ( CampfireIntensityFlickerValue / 2.0f ) ) + ( CampfireIntensityFlickerValue / 2.0f ) ); 64.                     } 65.                     else light.intensity = C

47、ampfireIntensityBaseValue + Random.Range( 0.0f, CampfireIntensityFlickerValue ); 66.                 } 67.                 // If campfire method is Range OR Both 68.                 if( campfireMethod == campfireMethods.Range || campfireMethod == campfireMethods.Both ) 69.                 { 70.

48、                     // If Range style is Sine 71.                     if( campfireRangeStyle == campfireRangeStyles.Sine ) 72.                     { 73.                         // Cycle the Campfire angle 74.                         CampfireSineCycleRange += CampfireSineCycleRangeSpeed; 75.  

49、                      if( CampfireSineCycleRange > 360.0f ) CampfireSineCycleRange = 0.0f; 76.                         // Base + Values 77.                         light.range = CampfireRangeBaseValue + ( ( Mathf.Sin( CampfireSineCycleRange * Mathf.Deg2Rad ) * ( CampfireSineCycleRange / 2.0f ) ) +

50、 ( CampfireSineCycleRange / 2.0f ) ); 78.                     } 79.                     else light.range = CampfireRangeBaseValue + Random.Range( 0.0f, CampfireRangeFlickerValue ); 80.                 } 81.                 break; 82.             // If Flickering Style is Fluorescent 83.       

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服