Unity script Execution Sequence test in the Hierarchy Panel 2

Source: Internet
Author: User

The previous article tested the effect of the build order on the order of execution, linking: Link

This article mainly tests the loop order of the three common messages in Awake,onenable,start

First one of the simplest print test code

void Awake ()    {        Debug.Log ("awake" + name);    }     void onenable ()    {        Debug.Log ("onenable" + name);    }     void Start ()    {        Debug.Log ("Start" + name);    }
Print Message

The test results are awake and onenable in the first cycle, start in the second cycle

Then test the order of dynamic creation

 Public TMP template; void Start () {    var go = instantiate (template.gameobject);    Print ("--creater modify--");    Go. SetActive (true);}
Dynamic Create

Awake and onenable are called first, and there is no chance of invoking initialization before this.

However, there are workarounds to save prefab as inactive and activate after initialization:

Unity script Execution Sequence test in the Hierarchy Panel 2

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.