System call methods in Unity3d

Source: Internet
Author: User

In Unity3d some methods are not manually called by the programmer, but the Unity3d tool itself is designed to decide to call automatically, but the timing and circumstances of the call are different, here is a brief introduction:

Awake: As the name implies, Unity3d's script wakes up with a method that needs to be called, which is earlier than the Start method and executes once.

Start: Can be understood as a constructor for a class, or an init function that initializes various variables and executes only once.

Update: callback function similar to Flash AS3 onframe, each frame callback.

Fixedupdate: Every frame is executed, when processing rigidbody, you need to use fixedupdate instead of update. For example: When you add a force to a rigid body, you must apply a fixed frame in the fixedupdate instead of the frame in the update. (both frame lengths differ) Fixedupdate, every fixed frame is executed once, and update is different fixedupdate is rendered frame execution, if your rendering efficiency is low, fixedupdate calls will be followed down. The Fixedupdate comparison is applicable to the calculation of the physics engine because it is related to each frame rendering. Update is more appropriate for control.

Lateupdate: Callback every frame, but is called after update.

Ongui: Callback per frame for drawing GUI objects.

Reset: The user clicks the Reset button on the inspector or is called the first time the component is added. This function is called only in edit mode. Reset is most commonly used to give a default value that is most commonly used in the View panel.

Ondisable: Ondisable will be called when an object is destroyed and can be used for arbitrary cleanup of code. When the script is unloaded, ondisable is called, and Onenable is called after the script is loaded. Note: ondisable cannot be used in a synergistic program.

Ondestory: This function is called when Monobehaviour will be destroyed. The OnDestroy will only be called on a game object that has been activated in advance. Note: OnDestroy also cannot be used in a synergistic program.

The above description of each callback function is relatively abstract, the specific feeling still need to use in the IDE environment to realize.


This article is from the "8403723" blog, please be sure to keep this source http://8413723.blog.51cto.com/8403723/1705418

System call methods in Unity3d

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.