Unity3d the management mechanism of component components

Source: Internet
Author: User

Sun Guangdong 2015.5.16

We all know that unity management Gameobject is a structure that uses a tree structure that is in the hierarchy panel. But how does it manage the components?

A colleague's test found the phenomenon:

The test is as follows: In U5, create a new button first.


Add a script to handle the response of the click button:

Using unityengine;using unityengine.ui;using System.collections;public class Testcomponent:monobehaviour {public void OnClick () {var text = Findobjectoftype (typeof (Text)) as Text;debug. Log ("Now is:" + text.transform.parent.gameObject.name);D Estroy (text);}}
Run the program and click to see the log output



Then we're creating a button,


For this output, there will be doubt, for the social output order is button2--"Button1 it?"

Then adjust the order of the hierarchy panel.


The result is the same, so. Unity's management of these components is more like stack stack structure storage: "LIFO"

Each time a new gameobject is created, Unity automatically categorizes the components on the game object and places them in their own stack. Unity maintains a stack for each component.




Unity3d the management mechanism of component components

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.