2014-08-13 19:11:19|?次阅读|上传:huigezrx【已有?条评论】发表评论
关键词:Unity3D, 游戏, 虚拟现实|来源:唯设编程网
Unity Manual > User Guide > Working with Assets > Using Scripts
Unity手册-> 用户指南 ->与资产合作->使用脚本
This is a short introduction on how to create and utilize scripts in a project. For detailed information about the Scripting API, please view the Scripting Reference. For detailed information about creating game play through scripting, please view the Creating Gameplay page of this manual.
这是一个小的介绍如何在一个项目里建立和使用脚本。关于脚本API的详细信息,请查看脚本引用。关于通过脚本建立游戏玩家的详细信息,请查看本手册的建立游戏玩家页。
Scripting inside Unity is done by writing simple behaviour scripts in JavaScript, Boo or C#. You can use one or all scripting languages in a single project, there is no penalty for using more than one. Unless stated otherwise, all the scripting examples are in JavaScript.
在Unity里的脚本的完成通过编写简单行为脚本在JavaScript, Boo 或 C#之内。你可以使用一个或所有简本语言在一个独立的项目中,使用多于一个没有损失。除非另有说明,所有的脚本例子是JavaScript的。
Creating new scripts 建立新脚本
Unlike other assets like Meshes or Textures, Script files can be created from within Unity. To create a new script, open the Assets->Create->JavaScript (or Assets->Create->C Sharp Script or Assets->Create->Boo Script) from the main menu. This will create a new script called NewBehaviourScript and place it in the selected folder in Project View. If no folder is selected in Project View, the script will be created at the root level.
和其它资产不同,像网格或纹理,脚本文件可以Unity内部被建立。建立一个新的脚本,从主菜单打开Assets->Create->JavaScript(或Assets->Create->C Sharp Scrip 或Assets->Create->Boo Script)。这将建立一个称为NewBehaviourScript的新脚本并将它放置在项目视图里选择的文件夹中。
You can edit the script by double-clicking on it in the Project View. This will launch Unitron, the script editor for Unity. You do all your scripting in an external text editor like Unitron, and not in Unity directly. To set the default script editor, change the drop-down item in Unity->Preferences->External Script editor.
你可以在项目视图里通过在脚本上双击编辑它。这将启动Unitron,Unity的脚本编辑器。在外部文本编辑器里你处理所有你脚本像Unitron一样,但不如在Unity里直接。设置默认的脚本编辑器,在Unity->Preferences->External Script editor里(在windows上是 Eidt->Preferences->External Script editor)更改下拉框的项目
These are the contents of a new, empty behaviour script: 这些是新的内容,空白行为脚本:
function Update () { }
A new, empty script does not do a lot on its own, so let's add some functionality. Change the script to read the following: 一个新的,空白脚本不做它自身的任何事情,因此让我们添加一些功能。修改脚本阅读如下:
function Update () { print("Hello World"); }