[Unity-10] Life Cycle of Unity scripts

Source: Internet
Author: User

Anyone who has developed Android should know that every activity in Android has a set of complete lifecycles, and unity scripts have similar lifecycles. Let's take a look at them.

1,Awake ():Script wake-up. This method is the first method executed when the script is generated. It is used to initialize the script. The script is executed only once throughout the lifecycle.

2,Start ():The script starts. This method is executed only once after awake.

3,Update ():Script update. This method is executed after start (), and each frame is executed once. The higher the frame rate, the more frequent the execution.

4,Lateupdate ():Postpone update. This method is executed after Update (). The number of executions is the same as that of update.

5,Fixedupdate ():Fixed update. This method executes a fixed number of times per second. You can select "edit"-> "project"-> "Settings"-> "time ", modify "fixed timestep" in the Inspector view on the right ". The advantage of this function is that the number of executions per second is fixed and suitable for some operations with similar requirements.

6,Ongui ():Draw the interface. This method is also executed once per frame to draw the interface.

7,Ondestroy ():Destroy. Called before the current script is destroyed. Some things to be sorted out before the script is destroyed can be executed in this function.


I personally feel that the life cycle naming of unity is not as easy to understand as that of Android. However, the functions are relatively complete.

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.