for loop inside of another crashes unity

Well, I’m simply trying to create a simple randomly generated game. I wrote these lines of code to get started, but when I press the play button the editor freezes and I have to force shut-down unity. This only seems to happen when mapsize is bigger than 0.

Why is this, and how can I solve it? I’m not sure if this is a bug, or if I did something wrong.

using UnityEngine;
using System.Collections;

public class generatorScript : MonoBehaviour {
    Transform t;
    GameObject go;

    public int mapsize;

	void Start ()
    {
        generate();
	}

    void generate()
    {
        for (int x = 0; x < mapsize; x++)
        {
            for (int y = 0; y < mapsize; x++)
            {
                print(x + " " + y);
            }
        }
    }
}

Thanks for the help!

y stays 0 and Unity falls in an endless loop :slight_smile:

In line 19 do y++ instead of x++

for (int y = 0; y < mapsize; y++)