using UnityEngine;using System.Collections.Generic;////// Sprite is a textured element in the UI hierarchy./// /// public partial class UISprite : UIBasicSprite{public void OnInitNew(){OnInit();}}
////// Auto-upgrade. /// protected override void OnInit () { Debug.Log("Chu SHiHua"); if (!mFillCenter) { mFillCenter = true; centerType = AdvancedType.Invisible;#if UNITY_EDITOR NGUITools.SetDirty(this);#endif } base.OnInit(); }
public void OnInit2() { OnInit(); }
递归
void WhileFindChild(Transform transform) { Transform temp = transform; Debug.Log(""+temp.name); if (transform.GetComponent()) { transform.GetComponent ().OnInit2(); } if (transform.GetComponent ()) { transform.GetComponent ().OnInit2(); } if (temp.childCount > 0) { foreach (Transform item in temp) { UILabel label = item.GetComponent (); if (label) { label.OnInit2(); } UISprite sprite = item.GetComponent (); if (sprite) { sprite.OnInit2(); } temp = item; WhileFindChild(temp); } } }