GUI.Window with a for loop

I am trying to add character slots into my GUI. I am using a for loop to iterate through for the number of max character slots. Each time it iterates through the loop, it either adds a button or a Box depending on how many characters you have created.

The problem is, its not showing up on my screen. I believe this is because I have an if statement and the for loop only runs if the “if” statement is true. However, if I dont put the “if” statement, then the loop runs forever.

How can I use a for loop in OnGUI without it running forever, but also without it not showing up when the if statement is false?

Here is my last attempt: I put it into a GUI.Window with a function hoping that might solve the issue but it still doesn’t show up.

Its in C# btw:

void OnGUI()
	{
		GUI.Window(1 , new Rect(20,100, 300, 1450), CharacterSlots, "Select a Character", myStyle);
        }

//Character slots window function
void CharacterSlots(int windowID)
	{
		if(addCharacterGui)
		{
			for(int cnt = 1; cnt <= maxNumberOfCharacters; cnt++)
			{
				if(cnt <= MyCharacters.Count)
				{			
					if(GUI.Button(new Rect(offset, offset + charButtonSeperate, charButtonWidth, charButtonHeight), "Player Name:"))		//+ Other stuff about the character... Level, etc.
					{
						//If double click?
						Application.LoadLevel("MainMenu");
					}				
				}
				
				else
				{
					Debug.Log ("Blank char slot created");
					GUI.Box(new Rect(offset, offset + charButtonSeperate, charButtonWidth, charButtonHeight), "Character ");
				}
				Debug.Log(charButtonSeperate);
				charButtonSeperate += 280;
				Debug.Log(cnt);

				if(cnt >= maxNumberOfCharacters)
				{
					addCharacterGui = false;
				}
			}	
		}
	}

It was something to do with how I was adding charButtonSeperate constantly. I changed it to GUIlayout instead of the fixed GUI and its working fine.