Unity3D manages Component components.

Source: Internet
Author: User

Unity3D manages Component components.

Sun Guangdong 2015.5.16

We all know that Unity manages GameObject in a tree structure that is in the Hierarchy panel. But how does one manage components?

My colleague's test found this phenomenon:

Test: In U5, create a new Button.


Add a script to process the response of the clicked 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:" + text. transform. parent. gameObject. name); Destroy (text );}}
Run the program and click View Log output.



Then we create a Button,


There is a question about this output. What is the output order of "Button2 --" Button1?

Adjust the Hierarchy panel order.


The results are the same, so. The management of these components by unity is more like Stack-Stack structure storage: [first, first, and foremost]

Every time a new GameObject is created, unity will automatically classify the components on the game object and place them in their respective stacks. Unity maintains a Stack for each component.




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.