脚本

脚本的最大特点就是用少量的代码实现繁多的功能,避免大量的代码。Untiy3D这一块可以使用脚本做很多东西,那么我们开始学习脚本吧。

有关Unity3D 脚本的API所有文档盆友们都可以去这里查阅。


官方文档

(虽然我英语不好但是、给你们在其中加中文翻译吧、至少让你们好看点)

脚本描述

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:

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# & Boo for information about how to use C# or Boo scripts.

你可能感兴趣的:(脚本)