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.