Value won't change/GUI won't draw

So I’m trying to make a level selection screen. I’ve started by making a grid of buttons to fill the screen, but it doesn’t seem to draw ANYTHING to the screen. I tried placing a few Debug.Log()s throughout my code. Here’s my code.

using UnityEngine;
using System.Collections;

public class LevelSelector : MonoBehaviour {

	public int world = 1;
	public Vector2 buttonSize = new Vector2(100, 50);
	public Vector2 Spacing = new Vector2(10, 10);
	public GUISkin skin;
	
	private int rowLengthX;
	private int rowLengthY;

	private int x = 10;
	private int y = 10;

	void Start() {
		rowLengthX = Mathf.RoundToInt(Screen.width / (Spacing.x + buttonSize.x));
	    rowLengthY = Mathf.RoundToInt(Screen.height / (Spacing.y + buttonSize.y));
	    Debug.Log(rowLengthX + ", " +rowLengthY);

	    
	}

	void OnGUI() {
		

		GUI.skin = skin;

		int ButtonNumber = 0;

		for(int butx = 1; butx == rowLengthX; butx++) {
			x = Mathf.RoundToInt(butx * (Spacing.x + buttonSize.x));
			ButtonNumber++;
			for(int buty = 1; buty == rowLengthY; buty++) {
				y = Mathf.RoundToInt(buty * (Spacing.y + buttonSize.y));

				if(GUI.Button(new Rect(x, y, buttonSize.x, buttonSize.y), "Button #" + ButtonNumber)) {

				}
			}

		}

		Debug.Log(x + ", " + y);

		x = 10;
		y = 10;
	}
}

So at the end of my OnGUI(), the Debug.Log() always displays “10, 10”, which leads me to believe that either A) the value is resetting itself somehow, or B) the value doesn’t change at all. But if it’s still at 10, 10, then the buttons should be drawing at 10, 10–but oddly enough, nothing. Does anybody know what’s causing this? Does anybody also know why nothing is drawing to the screen?

All help is appreciated.

It’s probably because of your for loop’s conditional statement. Try changing the == to a <=.
When the loop starts, the conditional statement is immediately false, resulting in the loop’s body not being executed.

If that’s not it, maybe it has something to do with the GUISkin you’re using, though I doubt it. In any case, try to not assign a skin and see if nothing is being drawn. I’m pretty sure that the loops are causing the issue though.