Answers for "unity get list of children"

C#
1

unity get list of children

List<Transform> children = new List<Transform>(transform.GetComponentsInChildren<Transform>());
//!!!!DISCLAMER!!!! This will also include the parent object for whatever reason.
//Heres a less elegant solution that wont include parent:
List<Transform> children = new List<Transform>();
foreach (Transform tr in transform) children.Add(tr);
Posted by: Guest on August-12-2021
7

unity get all children

foreach (Transform child in transform)
Posted by: Guest on March-22-2020
6

unity get all children

foreach (Transform child in parent) {
  //Your code
}
Posted by: Guest on June-06-2020

C# Answers by Framework

Browse Popular Code Answers by Language