查找子物体
public static GameObject FindChildBreadth(GameObject root, string name) { if(root == null) { LogMan.Logout(LogMan.Tag.Error, string.Format("GameObject {0} is null",name)); return null; } if (root.name == name) return root; //Queue<GameObject> queue = new Queue<GameObject>(); //mFindAssistQueue.Clear(); mFindAssistQueue.Enqueue(root); int nCount = 0; Transform tmpTr = null; while (mFindAssistQueue.Count > 0) { GameObject current = mFindAssistQueue.Dequeue(); GameObject child = null; tmpTr = current.transform; nCount = tmpTr.childCount; for (int i = 0; i < nCount; i++) { child = tmpTr.GetChild(i).gameObject; if (child.name == name) { mFindAssistQueue.Clear(); return child; } else { mFindAssistQueue.Enqueue(child); } } } return null; }