Unity3d Event function collation, event, callback function, message handling __ function

Source: Internet
Author: User

Unity3d Event function collation, event, callback function, message handling

The base class of all the control scripts in Unity3d Monobehaviour Some virtual functions are used to draw the callback of the events, and can be directly understood as the event function, for example, we are very clear start,update and other functions, the following summary.

Awake

Called when the current control script instance is loaded. Typically used to initialize the entire instance.

Start

Called before the current control script executes the update for the first time.

Update

Each frame is executed once. This is the most commonly used event function.

Fixedupdate

Each fixed frame is plotted once, and unlike update, Fixedupdate is the rendering frame execution, and if your rendering efficiency is low, the number of Fixedupdate calls will follow. Fixedupdate comparisons apply to the calculation of physical engines because they are related to each frame rendering. Update is more suitable for control.

Lateupdate

At the end of each frame, the call is dropped after all updates are completed, and is more appropriate for command script execution. Official online example is the camera following, all update operations to follow the camera, or there may be the camera has been advanced, but the perspective of the role of the empty frame appears.

Reset

This is the editor mode in case you click the Reset button (if any) called, you can do debugging in the initialization work.

Onapplicationfocus
Onapplicationpause
Onapplicationquit

Applications lose focus, applications are paused, and messages are sent when the application exits.

Onbecameinvisible
Onbecamevisible

This message is sent when the script Host (not) is displayed by any camera.

Oncollisionenter
Oncollisionexit
Oncollisionstay

The first two are sent when other collisions or rigid bodies (Collider/rigidbody) and parameters collide or rigid bodies (collider/rigidbody) overlap and exit. Each frame sends a stay message when they are kept in an overlapping state.

Onconnectedtoserver
Ondisconnectedfromserver
Onfailedtoconnect
Onfailedtoconnecttomasterserver

The first two send this message when the client successfully connects to the server or disconnects the server.
The latter two trigger when the connection fails

Onmasterserverevent

triggered when the master server sends a report.

Onnetworkinstantiate

Triggered when an object is network.instantiate. (not yet studied)

onplayerconnected
onplayerdisconnected

Triggered when the player is successfully connected/offline on the server.

Oncontrollercolliderhit

This message is triggered when the controller and parameter Controllercolliderhit collide. The official example can be used to move an object, and when the character touches the parameter object, you can manipulate the movement of the object in this function, and so on.

Onparticlecollision

triggered when a particle hits a collision Body (collider).

Ondisable
Onenable

triggered when the script host is enabled or disabled.

Ondrawgizmos
ondrawgizmosselected

When the editor state is drawn, the gizmos and gizmos are triggered when selected.
Note: Gizmos See my other blog, he used to do his own component when used, such as path point mapping.

Ongui

Triggers when drawing a GUI. The GUI menu is generally drawn in this function.

Onjointbreak

(not yet studied)

onlevelwasloaded

triggered when the new level (Unity Package) is read.

OnMouseDown
Onmousedrag
Onmouseenter
Onmouseexit
OnMouseOver
OnMouseUp

Mouse events are triggered when the mouse interacts with the GUI or the collision Body (Collider). What needs to be explained is that the drag is actually the mouse down after the up to the last every frame will send this message.

Onpostrender

This function is used only for scripts hosted for cameras. This message is triggered when all rendering is complete in this camera range.

Onprecull

This function is used only for scripts hosted for cameras. This message is triggered when this camera strips out a rendering scene. (not validated)

OnPreRender

This function is used only for scripts hosted for cameras. This message is triggered when the camera starts rendering a scene.

Onrenderimage

triggered when all rendering complete image postprocessing effects (only Pro version support).

Onrenderobject

This function is used only for scripts hosted for cameras. Triggers when a graphics.drawmeshnow or other function is used to draw an object that has been created.

Onserializenetworkview

Onserverinitialized

Triggered when Network.initializeserver is complete.

Ontriggerenter
Ontriggerexit
Ontriggerstay

A series of messages when the collision Body (Collier) touches the triggering region (trigger).

Onwillrenderobject

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.