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. 用FireMonkey写QQ皮肤

    这是运行在Windows平台的效果,同样不需要改一行代码就可以运行在Mac Os,并且效果完全相同: 用FireMonkey做界面速度非常快,其提供的Effect ,Filter,Animation等 ...

  2. spring mvc出现 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'endtime'

    在使用spring mvc中,绑定页面传递时间字符串数据给Date类型是出错: Failed to convert property value of type [java.lang.String] ...

  3. android studio sqlite操作代码片段

    SQLiteDatabase db;Cursor cur; SimpleCursorAdapter adapter;   // 打开或创建数据库db = openOrCreateDatabase(DB ...

  4. 漫游Kafka入门篇之简单介绍

    介绍 Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了普通消息系统的功能,但具有自己独特的设计.这个独特的设计是什么样的呢?   首先让我们看几个基本的消息系统术语: Kafka将消息以 ...

  5. Android 系统属性

    /************************************************************************ * Android 系统属性 * 说明: * 由于需 ...

  6. HDU 5344 MZL's xor (水题)

    题意:给一个序列A,设序列B的中的元素有(Ai+Aj)(1≤i,j≤n),那么求B中所有元素的异或之和.而序列A是这样来的:A1=0,Ai=(Ai−1∗m+z) mod l. 思路:相同的元素异或结果 ...

  7. php排序测试

    对 http://www.cnblogs.com/kudosharry/articles/2521621.html 这个补充的调用系统sort()函数的测试结果 1000个随机数: 直接插入排序:时间 ...

  8. 統計分析dbms_stats包与analyze 的区别

    Analyze StatementThe ANALYZE statement can be used to gather statistics for a specific table, index ...

  9. Android高手进阶教程(五)之----Android 中LayoutInflater的使用!

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://weizhulin.blog.51cto.com/1556324/311450 大 ...

  10. 在SQL语言中,join什么时候用,什么时候不用啊?请高手举例解释一下。谢谢

    JOIN 在内连接时,可以不使用,其它类型连接必须使用.如SELECT * FROM TABLEA INNER JOIN TABLEB ON A.ID=B.ID可以这样写:SELECT * FROM ...