Skip to content

Instantly share code, notes, and snippets.

@korchoon
Created March 30, 2020 06:58
Show Gist options
  • Save korchoon/c8db25067e30721e713328230b62d3d1 to your computer and use it in GitHub Desktop.
Save korchoon/c8db25067e30721e713328230b62d3d1 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment