GUI 2D Array

I want to create a grid of gui boxes (or labels) and control the properties of each box or label.
I defined :

public GUIStyle[,] st=null;

and in Start() I have:

st = new GUIStyle[rows,columns];
for (int i=0;i<rows;i++){
			for (int j=0;j<columns;j++){
				st[i,j]=new GUIStyle();


and in OnGui() I have:

for (int i=0; i<rows; i++) {
  for (int j=0; j<columns; j++) {
    GUI.Label (new Rect (boxWidth*j, boxHeight*i, boxWidth, boxHeight), new GUIContent (""+conTstr[i,j]),st[i,j]);

now, I need your help for adding border on box and I want to change background color of each box by code (based on random number e.g. if rnd < 10 background box color=red)


You can do both by utilizing the GUIStyle values.

You can make a texture with border and use it as the background of your image .

For example, the background colors:

style.normal.background = MakeTex(2, 2, new Color(0.75f, 0.75f, 0.75f))

public Texture2D MakeTex(int width, int height, Color col)
    Color[] pix = new Color[width * height];
    for (int i = 0; i < pix.Length; ++i)
        pix *= col;*

Texture2D result = new Texture2D(width, height);
return result;
The example texture doesn’t have any borders.