Skip to content

Instantly share code, notes, and snippets.

@sergiobd
Created October 16, 2019 03:34
Show Gist options
  • Save sergiobd/45455b2e9c361723cbf763134face317 to your computer and use it in GitHub Desktop.
Save sergiobd/45455b2e9c361723cbf763134face317 to your computer and use it in GitHub Desktop.
/*
Utility function for looping (deeply) through all children in a transform
Usage:
List<Transform> childs = new List<Transform>();
Utilities.GetAllChildren(queryParent.transform, ref childs);
*/
static class Utilities
{
public static void GetAllChildren(Transform parent, ref List <Transform> transforms)
{
foreach (Transform t in parent) {
transforms.Add(t);
GetAllChildren(t, ref transforms);
}
}
}
@sergiobd
Copy link
Author

A script for getting all childs (including grandchilds and further), from a parent transform. Unity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment