How to limit how objects get stored in GameObject[] array

Hi All,

I have a scene with about 20 gameobjects with the same tag. How do I get an array of only 6 or 7 of them? Right now I have something like this:

public GameObject[] Tiles;

void Start () 
{
        Tiles = GameObject.FindGameObjectsWithTag("Tile");
}

Do i create a for loop that adds one gameobject to the array six times? if so, how do you add gameobjects like that? and will it be random?

Thanks in advance

This should work:

void Start ()
{
  // This is an inefficient way of getting your tiles
  // A more efficient way would be for a component in each
  // Tile registering itself with this component when enabled
  Tiles = GameObject.FindGameObjectsWithTag("Tile");

  // This will randomly sort your objects (if needs be)
  System.Array.Sort<GameObject> ((a, b) => Random.Range(-1, 2));

  // This will remove all but the first 6 gameObjects in Tiles
  System.Array.Resize<GameObject> (ref Tiles, 6);
}

So my final solution looks like this:

void Start () {
        Tiles = GameObject.FindGameObjectsWithTag("Tile");
        int tilecount = Tiles.Length;
        for (int i = 0; i < tilecount; i++) {
            GameObject temptile = Tiles*;*

int randomIndex = Random.Range(0, tilecount);
Tiles = Tiles[randomIndex];
Tiles[randomIndex] = temptile;
}
System.Array.Resize(ref Tiles, 6);
}
This provides the desired results. Now every time i start the game, a random 6 tiles are chosen.