Scripting Overview 脚本概述

翻译:脚本_树

This is a short overview of how scripting inside Unity works.

Scripting inside Unity consists of attaching custom script objects called behaviours to game objects. Different functions inside the script objects are called on certain events. The most used ones being the following:

这是一本关于脚本在Untiy中如何工作的简短概述。

脚本在Unity由附加自定义脚本对象到游戏对象构成。不同的函数在脚本对象内在特定事件被调用。以下最常用的:

Update:

This function is called before rendering a frame. This is where most game behaviour code goes, except physics code.

这个函数在运行一帧之前被调用,这是大部分的游戏行为代码在这里执行,除了物理代码。

FixedUpdate:

This function is called once every physics time step. This is the place to do physics-based game behaviour.

这个函数会在每个固定的物理时间步被调用一次。这是放置游戏基本物理行为代码的地方。

Code outside any function 函数外部代码 :

Code outside functions is run when the object is loaded. This can be used to initialise the state of the script.

  函数外部的代码在物体被加载时运行。这可以用来初始化脚本状态。

Note: Sections of this document assume you are using Javascript, but see Writing scripts in C# for information about how to use C# or Boo scripts.
注意:这个文档假设你使用的是Javascript,否则请查看 Writing scripts in C# (用C#编写脚本)来获取如何使用C#或Boo编写脚本。

You can also define event handlers. These all have names starting with On, (i.e. OnCollisionEnter). To see the full list of predefined events, see the documentation for MonoBehaviour.

也可以使用事件处理程序,这些函数的名字都开始于On(类似的OnCollisionEnter),看所有的预定义事件列表,查阅文档 MonoBehaviour .

Subsections 章节

最后修改:2011年10月7日 Friday 11:18

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。