I’m trying to put this group of GUILayout.Boxes in a GUILayout.Window . When I run the scene they don’t appear anywhere within the GUILayout.Window. But If I put them in a different function like Void OnGUI they appear in a group like they’re suppose to. Any idea why this is happening? Sorry if the bottom of my code is messed up. Whenever I try to post it the bottom gets completely messed up.
using UnityEngine;
using System.Collections;
public class RowsAndColumns : MonoBehaviour {
public const int rowSizeX= 8;
public const int columnSizeY= 5;
public int[,] rowColumnArray;
public Vector2 offSet = new Vector2 (100, 100);
public Rect windowRect0;
public int boxWidthHeight= 40;
public int boxSpacing= 2;
void OnGUI () {
windowRect0 = GUILayout.Window(0, windowRect0, DoMyWindow, "My Window");
}
void DoMyWindow(int windowID){
for (int i= 0; i < rowSizeX; i++)
{
for( int j = 0; j < columnSizeY; j ++ )
{
if( rowColumnArray[i,j] != null )
{
GUILayout.BeginArea(new Rect(offSet.x+j*(boxWidthHeight+boxSpacing), offSet.y+i*(boxWidthHeight+boxSpacing), boxWidthHeight, boxWidthHeight));
GUILayout.Box("A Box");
GUILayout.EndArea();
}
}
}
}
}