GUI 2D Array

Hi,
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++){
				stocksValue[i,j]=rnd.Next(1,10000);
				st[i,j]=new GUIStyle();
				st[i,j].fontSize=50;

			}
		}

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)

Thanks

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);
result.SetPixels(pix);
result.Apply();
return result;
}
The example texture doesn’t have any borders.