Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save twobob/45e1a46760a2a9791eac17376f425ff5 to your computer and use it in GitHub Desktop.
Save twobob/45e1a46760a2a9791eac17376f425ff5 to your computer and use it in GitHub Desktop.
void GetComponentsInChildrenRecursive<T> (Transform parent, List<T> buffer)
where T : Component
{
foreach (Transform t in parent) {
var c = t.GetComponent<T> ();
if (c) {
buffer.Add (c);
}
GetComponentsInChildrenRecursive (t, buffer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment