public class Cell : MonoBehaviour {
public int X, Y;
public Move = false;
void OnMouseDown(){
Move = true;
}
void Update(){
if(Move) Debug.Log(X + "," + Y);
}
}
#-----------------------------------------------------
public class Board : MonoBehaviour {
public Dictionary<(int, int), GameObject> Cells = new Dictionary<(int, int), GameObject>();
void Start(){
CreateBoard();
}
void CreateBoard(){
for(int y = 0; y < 5; y++){
for(int x = 0; x < 5; x++){
GameObject PrefabResources = Resources.Load("Prefabs/test", typeof(GameObject)) as GameObject;
Cells[(x, y)] = Instantiate(PrefabResources, new Vector3(x, y, 0), Quaternion.identity) as GameObject;
Cells[(x, y)].AddComponent<Cell>();
Cells[(x, y)].GetComponent<Cell>().X = x;
Cells[(x, y)].GetComponent<Cell>().Y = y;
}
}
}
}