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