2019-02-17 【Mine】递归检索(带返回值)

public Transform DeepFind(Transform parentTrans, string controlName)
{
    Transform target = parentTrans.Find(controlName);
    if (target != null)
    {
        return target;
    }
    else
    {
        List childrenTranss = parentTrans.GetChildren();
        foreach (var x in childrenTranss)
        {
            target = DeepFind(x, controlName);
            if (target != null)
            {
                return target;
            }
        }
    }
    return null;    //此时此刻,应该是真的没有
}

你可能感兴趣的:(2019-02-17 【Mine】递归检索(带返回值))