How to make certain tiles a certain state

I am trying to make a grid system and I finally found a grid generator using tiles. But, my next step is to make a system that creates allows me to create boundaries between the different “counties”. I thought maybe I could define each individual tile and then define the tile to wich county it belonged to (for starters neutral, red blue, green, yellow). Since I am a noob at C# I need help integrating this into what I believe is the correct place to put it in.

So far my code is as fallows

using UnityEngine;
using System.Collections;

public class mapGenerator : MonoBehaviour {

	public Transform tilePrefab;
	public Vector2 mapSize;

	public float outlinePercent;

	void Start() {
		genMap ();

	public void genMap(){

		string holderName = "Generated map";
		if (transform.FindChild (holderName)) {
			DestroyImmediate (transform.FindChild (holderName).gameObject);

		Transform mapHolder = new GameObject (holderName).transform;
		mapHolder.parent = transform;

		for (int x = 0; x < mapSize.x; x++) {
			for (int y = 0; y < mapSize.y; y++) {
				Vector3 tilePos = new Vector3 (-mapSize.x / 2 + 0.5f + x, 0, -mapSize.y/2 + 0.5f + y);
				Transform newTile = Instantiate (tilePrefab, tilePos, Quaternion.Euler(Vector3.right*90)) as Transform;
				newTile.localScale = * (1 - outlinePercent);
				newTile.parent = mapHolder;


Create a tile class

public class Tile : MonoBehaviour {
    public bool Walkable;
    public bool IsCountyBorder;
    public int SomeInt;

Drag that script onto your tile prefab. Then change the type of your prefab variable

public Transform tilePrefab;


public Tile tilePrefab;

Then drag the prefab to the tilePrefab field again in inspector. Now you can get a reference to the Tile script of the tile every time you instantiate one

Tile newTile = Instantiate (tilePrefab, tilePos, Quaternion.Euler(Vector3.right*90)) as Tile;
newTile.IsCountyBorder = true;

I would imagine you want to put the created tiles into an array so you can reference them later and for example easily check which tile some actor in your game is on. Also you probably need a way to determine the locations of county tiles etc beforehand so you can create the tilemap based on that data.

There’s many things here that i think you could learn more easily by following some grid based game tutorial. Or a tutorial for a graphically tile based game, depending on what tou actually want from the tile-basedness. Otherwise you might have to ask about 50 more questions to get things going.