Display buttons based on the amount of children

I want to show a GUI with a number of buttons depending on the amount of children the selected GameObject has.
Each button should show a Texture2D image that is assigned as a variable via a script (Obj_Properties) inside each children.
I`ve been trying to figure out how to do this but I don’t think I have the knowledge to do so…

This is what I wrote so far for the GUIOn and it just doesn’t seem to work:

	//number of children in Object.
	var numberOfItems : int = Player_Navigation.selectedObject.childCount;

	//number of children in Object that contain the Obj_Properties script (where I get the thumbnail image)
	var childrenInObject = Player_Navigation.selectedObject.GetComponentsInChildren(Obj_Properties);

	var yOffset  = 0;
	
	GUILayout.BeginArea(Rect (25,25,150,300));
	GUILayout.BeginVertical();
		for(i in childrenInObject){
			if( GUI.Button (Rect ( 30, 30 + yOffset, 30, 43), GUIContent("", childrenInObject*.GetComponent(Obj_Properties).objThumbnail))){*
  •  		Debug.Log("something :" + i );*
    
  •  	}*
    
  •  	yOffset += 30;*
    
  •  }*
    
  • GUILayout.EndVertical();*
  • GUILayout.EndArea();*
    Any help very welcome!

You are nearly there! Because you are using in the if line should read:

    if( GUI.Button (Rect ( 30, 30 + yOffset, 30, 43), GUIContent("", i.objThumbnail))){