Unity3d event processing functions

Source: Internet
Author: User

In unity3d, the base class monobehaviour of all control scripts has some virtual functions used to draw the callback of events.

It can be directly understood as an event function.

Awake

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

Start

The current control script is called before the first update execution.

Update

Each frame is executed once. This is the most common event function.

Fixedupdate

Each fixed frame is executed once. Unlike update, fixedupdate is used to render frames.

When the call rate is low, the number of fixedupdate calls will decrease. Fixedupdate is applicable to computing of physical engines.

Because it is related to the rendering of each frame. Update is more suitable for control.

Lateupdate

The call is completed after each frame is executed. It is suitable for Executing command scripts only after all updates are completed. Official Website

In the above example, we follow the camera after all update operations. Otherwise, the camera may appear.

It has been promoted, but there is no empty frame for the role in the perspective.

Reset

This is called by clicking the reset button (if any) in the editor mode. You can debug it here.

Initialization.

Onapplicationfocus
Onapplicationpause
Onapplicationquit

The application loses focus, the application is suspended, and the message is sent when the application exits.

Onbecameinvisible
Onbecamevisible

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

Oncollisionenter
Oncollisionexit
Oncollisionstay

When other collision or rigid body (collider/Rigidbody) and parameter collision or Rigid Body

(Collider/Rigidbody. When they overlap, each frame will be sent

Send a stay message.

Onconnectedtoserver
Ondisconnectedfromserver
Onfailedtoconnect
OnfailedtoconnecttomasteRserver

This message is sent when the first two clients are successfully connected to or disconnected from the server.
The last two are triggered when the connection fails.

Onmasterserverevent

Triggered when the master server sends a report.

Onnetworkinstantiate

Triggered when the object is network. instantiate. (Not yet studied)

Onplayerconnected
Onplayerdisconnected

Triggered when the player successfully connects to or goes offline on the server.

Oncontrollercolliderhit

This message is triggered when the controller and the controllercolliderhit parameter collide. Official examples can be used for role Movement

When a role encounters an object with this parameter, you can operate and move the object in this function.

.

Onparticipant lecollision

Triggered when a particle hits a collider.

Ondisable
Onenable

Triggered when the Script Host is enabled or disabled.

Ondrawgizmos
Ondrawgizmosselected

It is triggered when gizmos and gizmos are drawn in the editor status.
Note: For details about gizmos, refer to my other blog, which is used for self-built components, such as path point painting.

Ongui

Triggered when drawing the GUI. The GUI menu is usually 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 collider. It must be noted that drag's

The message is sent every frame after the mouse is down and before it is up.

Onpostrender

This function is only used for scripts with the host as the camera. This message is triggered when all rendering within the camera range is complete.

Onprecull

This function is only used for scripts with the host as the camera. This message is triggered when the camera removes a Rendering scenario. (

Not verified)

Onprerender

This function is only used for scripts with the host as the camera. This message is triggered when the camera starts rendering a scenario.

Onrenderimage

This is triggered when all postprocessing effects (only supported by Pro) after the image is rendered.

Onrenderobject

This function is only used for scripts with the host as the camera. When graphics. drawmeshnow or other functions are used to draw

Triggered when the created object is rendered.

Onserializenetworkview

Onserverinitialized

Triggered when network. initializeserver is complete.

Ontriggerenter
Ontriggerexit
Ontriggerstay

A series of messages when the collision body (Collier) is exposed to the trigger area.

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.