how to get child objects transform in arry ?

Actually its a kind of weird problem i am trying to get child objects transform in arry

    public GameObject way;
public GameObject[] myway;

void Start () 
	for (int i = 0; i < way.transform.GetChildCount(); i++) 
	Debug.Log (way.transform.GetChild (i).name);
		myway *= 	way.transform.GetChild (i).transform;*
  • }*
    debug.log work well without getting objects in arry code line "myway = way.transform.GetChild (i).transform"
    but when i place this line of code it just show first game object.

you have to use array when you know the length. here you don’t know length so take a list


public List<GameObject> childList = new List<GameObject>();

void Start(){

	foreach (Transform t in transform) {
		childList.Add (t.gameObject);