Answers for "unity put children in list"

C#
1

unity put children in list

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

C# Answers by Framework

Browse Popular Code Answers by Language