korchoon
3/30/2020 - 6:57 AM

Transform Utils

public static Transform FindInChildren(this Transform self, string name)
{
    int count = self.childCount;
    for (int i = 0; i < count; i++)
    {
        Transform child = self.GetChild(i);
        if (child.name == name) return child;
        Transform subChild = child.FindInChildren(name);
        if (subChild != null) return subChild;
    }
    return null;
}