Skip to content

Instantly share code, notes, and snippets.

@birdinforest
Forked from mstevenson/gist:10706756
Last active April 15, 2017 02:52
Show Gist options
  • Save birdinforest/7529503db10991a8b59a to your computer and use it in GitHub Desktop.
Save birdinforest/7529503db10991a8b59a 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