How to generate random numbers?

Iā€™m creating a random tile-based map generator. I have pre-made sets of integers to make specific rooms or hallways for the generator but I want to be able to randomly select what integer set is made. Here is the level creator function ā€“ any help would be appreciated :slight_smile:

private void CreateLevel () {
		string[] mapData = new string[] {
			"03010", "03010", "03010", "22022", "22222"
		};

		int mapX = mapData[0].ToCharArray().Length;
		int mapY = mapData.Length;

		Vector3 worldStart = Camera.main.ScreenToWorldPoint (new Vector3 (0, Screen.height));
		for (int y = 0; y < mapY; y++) {
			char[] newTiles = mapData [y].ToCharArray ();
			for (int x = 0; x < mapX; x++) {
				PlaceTile (newTiles[x].ToString(), x, y, worldStart);
			}
		}
	}

You can use the Random.Range function so:

int randomNum = Random.Range(0,mapData.Length);
char[] newTiles = mapData [randomNum].ToCharArray ();

note that when using integers in Random.Range the maximum is not inclusive