Event Functions

  A key concept in games programming is that of making changes to position, state and behavior of objects in the game just before each frame is rendered. The Update function is the main place for this kind of code in Unity. Update is called before the frame is rendered and also before animations are calculated.

  

  The physics engine also updates in discrete time steps in a similar way to the frame rendering. A separate event function called FixedUpdate is called just before each physics update. Since the physics updates and frame updates do not occur with the same frequency, you will get more accurate results from physics code if you place it in the FixedUpdate function rather than Update.

  

  The LateUpdate function can be used to make additional changes at a point after the Update and FixedUpdate functions have been called for all objects in the scene and after all animations have been calculated. An example is where a camera should remain trained on a target object

  

Initialization Events

  The Awake function is called for each object in the scene at the time when the scene loads. Note that although the various objects' Start and Awake functions are called in arbitrary order, all the Awakes will have finished before the first Start is called.

GUI events

  You can detect mouse events that occur over a GameObject as it appears in the scene. This can be used for targetting weapons or displaying information about the character currently under the mouse pointer. A set of OnMouseXXX event functions (eg, OnMouseOverOnMouseDown) is available to allow a script to react to user actions with the mouse. For example, if the mouse button is pressed while the pointer is over a particular object then an OnMouseDown function in that object's script will be called if it exists.

Physics events

  The physics engine will report collisions against an object by calling event functions on that object's script. The OnCollisionEnterOnCollisionStay and OnCollisionExitfunctions will be called as contact is made, held and broken. The corresponding OnTriggerEnterOnTriggerStay and OnTriggerExit functions will be called when the object's collider is configured as a Trigger (ie, a collider that simply detects when something enters it rather than reacting physically). These functions may be called several times in succession if more than one contact is detected during the physics update and so a parameter is passed to the function giving details of the collision (position, identity of the incoming object, etc).

Event Functions的更多相关文章

  1. Execution Order of Event Functions

    In Unity scripting, there are a number of event functions that get executed in a predetermined order ...

  2. Unity3d - 初学篇 Event Functions 的 继承 机制

    我们知道Start() Update() 等之类的 事件函数 在Unity 主线程中是依次调用的.至于调用的顺序可以查手册. 由此继承机制也会发生一些改变. 测试一: public class MyT ...

  3. [转]Calling Web Service Functions Asynchronously from a Web Page 异步调用WebServices

    本文转自:http://www.codeproject.com/Articles/70441/Calling-Web-Service-Functions-Asynchronously-from Ove ...

  4. Unity 脚本生命周期流程图

    渲染 OnPreCull: 在相机剔除场景之前调用此函数.相机可见的对象取决于剔除.OnPreCull 函数调用发生在剔除之前. OnBecameVisible/OnBecameInvisible:  ...

  5. Microsoft Win32 to Microsoft .NET Framework API Map

    Microsoft Win32 to Microsoft .NET Framework API Map .NET Development (General) Technical Articles   ...

  6. Unity and C#: Game Loop (Awake, Start, Update)

    Introduction The central component of any game, from a programming standpoint, is the game loop. It ...

  7. JSBinding / About JSComponent and Serialization

    About JSComponent JSCompnent is a normal Unity script. It inherits from JSSerializer and JSSerialize ...

  8. 从Unity引擎过度到Unreal4引擎(最终版)

    原文地址:http://demo.netfoucs.com/u011707076/article/details/44036839 前言 寒假回家到现在已经有十多天了,这些天回家不是睡就是吃....哎 ...

  9. NGUI 基础知识

    UIRoot 管理 scalePixelPerfect : 像素匹配,图片不会被缩放,除非屏幕高度小于 Minimum Height 或者大于 maximum  Height,如果那样的话,就使用 F ...

随机推荐

  1. some resource favor

    http://www.moxiemanager.com/getit/ : picture file manage with blur 可以和Tinymce结合使用完美实现WYSIWYG的效果 http ...

  2. 在maven项目中使用mybatis-generator-maven-plugin生成mybatis代码

    项目整体的目录结构如下: pom.xml如下: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=&q ...

  3. 51nod1204 Parity

    如果sm[j]和sm[i]奇偶性相同,那么(i+1,j)个数为偶数如果奇偶性相同看成是朋友,不同的看成是敌人,那么就跟bzoj1370的做法差不多了. 如果奇偶性相同,就将x和y合并,x+n,y+n合 ...

  4. 漫游Kafka实战篇之搭建Kafka运行环境

    接下来一步一步搭建Kafka运行环境. Step 1: 下载Kafka 点击下载最新的版本并解压. > tar -xzf kafka_2.9.2-0.8.1.1.tgz > cd kafk ...

  5. 打印机C++

    m_prnDC.SetMapMode(MM_LOMETRIC);  m_iPrnX = m_prnDC.GetDeviceCaps(HORZRES);m_iPrnY = m_prnDC.GetDevi ...

  6. iOS8 LaunchScreen.storyboard

    我目前的需求是需要将启动图片通过LaunchScreen.storyboard  来实现. 我首先想到的是创建一个Sb,使用自动布局来布局imageview,并设置如下图: 布局好之后,在Image里 ...

  7. CodeIgniter的缓存设置

    数据库缓存 数据库缓存类允许你把数据库查询结果保存在文本文件中以减少数据库访问. 激活缓存需要三步: 在服务器上创建一个可写的目录以便保存缓存文件. 在文件 application/config/da ...

  8. 查询mysql数据库表的信息(表大小、数据大小、索引大小)

    select * from information_schema.TABLES where information_schema.TABLES.TABLE_SCHEMA='databasename' ...

  9. Mac设置截图保存位置

    补充: killall 用来杀死指定名字的进程 defaults 可以对一些系统属性进行read,write,delete操作 下面举几个常用的例子: 1.显示隐藏文件 defaults write ...

  10. C# winform 自定义控件

    近来因为项目的问题,开始研究winform自定义控件,这篇主要是将自定义控件的属性在属性编辑器中可编辑,如果你对自定义控件比较了解的,就不用继续往下看了 首先,我创建了一个类UserButton,继承 ...