Http://www.2cto.com/kf/201311/258811.html
1. To find an object in the hierarchy panel and destroy it, use the following code:
gameobject obj = Gameobject.find ("The name to look for"); Destroy (obj); if you want to find more objects, you can put the found object in an array, for the object name if it is in order or a certain rule of naming, you can also through the For Loop uniform search and assignment, For example, if the name of the object is House1,house2,......house10, define a string str; and an array of type Gameobject to save the found object, the loop code is as follows: for (int i=1;i <11,i++) { &NBSP;STR = "House"; str = str +i; a[i] = Gameobject.find ("str"); destroy (a[i]);// Destroy found objects } can also be searched by Gameobject.findwithtag ("tag name"), which is given to these objects in advance to add Tag 2.ngui hierarchies and non-hierarchical relationships The ngui hierarchy is the default hierarchical relationship that is created, including Uiroot, camera, Anchor,panel, non-Ngui hierarchies are Camera, and then create controls inside, but Camera hangs on Uicamera and UIPanel scripts. //The following sections of the online collection of 3. About Ngui Depth, level summary (after doing a lot of Ngui interface understanding will be deeper) 1, the same panel, The display of different sprites in the same Atlas is only controlled by depth, which is the most frequently used method. No matter how the Sprite's z-axis changes, the depth high must be in front. (The same Atlas is actually shared with the same z-axis depth) 2, under different panel, different sprites of the same Atlas are not controlled by the depth, but are controlled by the z-axis. At this point, just slightly adjust the z axis of one of the sprites can be, such as 0.1, you can control SPRITE display 3, under different panel, different Atlas of the Elves interspersed, controlled by the z axis. 4, under the same panel, different Atlas Sprite, controlled by the z axis, depth does not work. Projects to achieve a more complex interface, often use a number of Atlas, the skill interface as an example, the project commonly used images in the common Atlas, This is an atlas, the skill interface itself is unique elements, such as related to the skills of career background, counted as a second atlas, there are some skill icons, The icon is individually categorized into one set, and one is the atlas of the font. The basic one interface is so divided up to require a maximum of 4 atlas. The processing between Ngui's Atlas, by default, is differentiated by adjusting the z-value of the control, but here he can adjust the z-value of each control in the same atlas, which is actually not very good. Often there are layers of mutual occlusion, especially for the control of a more interface, a period of time back to modify the interface, the whole to crash. My approach is. In UIPanel, for each material add a layer of variables, when the same layer depends on the depth to determine the relationship, different layers depend on layer to determine the relationship between the front and back, when drawing Uidrawcall, Offsets the nodes by layer pairs. This frees you from the Z-value. If you have a problem with the layer, you can refer to this approach to deal with the layer relationship, simple, do the project's snare UI, there is no unresolved situation.
Unity destroys hierarchical objects and NGUI deep comprehension summary