array of childern

There is a way to do an array of object like to using Component.GetComponentsInChildren command?

I think you are probably after an array of GameObjects which are the children of the current object?

If so then you have two choices - all of the children or the immediate children. Unforunately you didn’t say what language you wanted it in…


using System.Collections.Generic;
using System.Linq;

//Immediate children

var myChildren = transform.Cast<Transform>().Select(t=>t.gameObject).ToArray();

//All children, not including self

var allChildren = GetComponentsInChildren<Transform>().Except(new [] { transform }).Select(t=>t.gameObject).ToArray();


import System.Linq;
var myChildren = transform.Cast.<Transform>().Select(function(t) { return t.gameObject; }).ToArray();

//All children not self 

var allChildren = GetComponentsInChildren(Transform).Except([transform]).Select(function(t) { return t.gameObject;}).ToArray();