/// /// 查找子节点 /// public static Transform FindDeepChild(GameObject _target, string _childName) { Transform resultTrs = null; resultTrs = _target.transform.Find(_childName); if (resultTrs == null) { foreach (Transform trs in _target.transform) { resultTrs = Utility.FindDeepChild(trs.gameObject, _childName); if (resultTrs != null) return resultTrs; } } return resultTrs; }
使用递归方法