纳金网

标题: 用unity3d实现5个flash常用功能 [打印本页]

作者: 会飞的鱼    时间: 2011-11-16 15:38
标题: 用unity3d实现5个flash常用功能


           发表 非常实用的技巧整理,特别是对学习过flash的朋友!
           

            i’ve been using Unity3D on and off for a week now. i’d burned through about a dozen beginner tutorials, and am a little overwhelmed by how much i don’t know about the engine, which enables you to create 3D games to deploy to a number of platforms, including the iPhone and web browsers.
         

           i’d look like a fool if i tried to write a tutorial at this point. So instead, i’ll share this list of translations of common Actionscript 3 coding tasks to the Unity3D engine’s JavaScript-like UnityScript language.
         








           1. Render an Object Visible or Invisible
         

           Actionscript 3:
         

           thing.visible = true; // or false
         

           UnityScript:
         

           thing.renderer.enabled = true; // or false
         

           2. Tint an Object
         

           Actionscript 3:
         

           var colorTransform:ColorTransform = new ColorTransform();
         

           colorTransform.color = 0xFF0000;
         

           thing.transform.colorTransform=colorTransform;
         

           UnityScript:
         

           thing.renderer.material.color = Color.red;
         

           3. Get a Random Number
         

           Actionscript 3:
         

           var someRandomNumberBetween0And5:int = Math.floor(Math.random()*5);
         

           UnityScript:
         

           var someRandomNumberBetween0And5:int = Random.Range(0, 5);
         

           4. Respond to a Key Press
         

           Actionscript 3:
         

           stage.addEventListener(KeyboardEvent.KEY
           


            _
           
           DOWN, doKeyDown);
         

           private function doKeyDown(e:KeyboardEvent):void
         

           {
         

           switch(e.keyCode)
         

           {
         

           case 32:
         

           // Space bar! Do stuff.
         

           break;
         

           default:
         

           break;
         

           }
         

           }
         

           UnityScript:
         

           if(Input.GetKeyDown("space"))
         

           {
         

           // Do stuff.
         

           }
         

           5. Open a Web Page
         

           Actionscript 3:
         

           navigateToURL(new URL("
           
            http://www.untoldentertainment.com
           
           "), "
           
            _
           
           self");
         

           UnityScript:
         

           Application.OpenURL("
           
            http://www.untoldentertainment.com
           
           ");
           

           原作者:Ryan Henson Creighton
         

作者: 菜刀吻电线    时间: 2012-2-13 23:21
发了那么多,我都不知道该用哪个给你回帖了,呵呵

作者: 菜刀吻电线    时间: 2012-4-30 23:26
我也来支持下

作者: 晃晃    时间: 2013-3-21 23:24
很经典,很实用,学习了!

作者: heise    时间: 2013-4-15 14:27
看了以后,都不知道怎么回!
作者: nts    时间: 2013-10-17 10:38
事件机制也能吗?flash的
作者: Icestar    时间: 2013-10-17 11:42
感谢分享
作者: gxf5168    时间: 2014-2-24 02:00
感谢分享
作者: orokborokhulu    时间: 2014-2-24 09:43
感谢分享
作者: BlueGem    时间: 2014-2-24 15:50
感谢分享




欢迎光临 纳金网 (http://course.narkii.com/club/) Powered by Discuz! X2.5