Hi everyone, is there a way to get GetComponentsInChildren(); to specify which children to add to someTransformArray? I want to add some of the gameobject’s children to the array but not all of them.
Public Transform someTransformArray;
someTransformArray = GetComponentsInChildren<Transform>();
If I understand correctly, you want to filter the return values from
GetComponentsInChildren() to only select the values of type
Transform and set it equal to an array?
someTransformArray = GetComponentsInChildren().OfType<Transform>().ToArray();
It reads almost like English; gotta love LINQ
Note: You may need to include
using System.Linq to use