How do I convert Component[] array into String[] with GetComponentsInChildren?


I am trying to dynamically define a GUI toolbar using GetComponentsInChildren();. Basically, the number of objects that have a Waypoint script attached will appear in a gui toolbar onscreen. The idea is that you click on each of these toolbar buttons to jump to a certain area (position and rotation) in the game.

I sucessfully have my array of components listed, but how do I convert the Component[] array into a String[] variable? The attached Waypoint script defines "var objectName : String" with the game object's name.


I don't know of any simpler way than iterating through the waypoints, and populating another array - something like this:

var names = new String[waypoints.Length];
var i = 0;
for (waypoint : Component in waypoints) {
    names[i++] =;