Run into a little problem here, its a simple for loop but for some reason it crashes my unity! I’ve been starring at this for so long now that I can’t see anything wrong with the code.
Weird thing is if i remove everything inside the loop, even the Debug.Log and play, everything works fine?!!?!?!??
void Start()
{
sprRect = grid_Icon.GetComponent<RectTransform>().rect;
float maxInARow = Mathf.FloorToInt(Screen.width / sprRect.width);
float maxInACol = Mathf.FloorToInt(Screen.height / sprRect.height);
gridPerView = maxInARow * maxInACol;
GenerateGrid();
}
void GenerateGrid()
{
for (int x = 0; x < screenWidth; x++)
{
for (int y = 0; y < screenHeigh; y++)
{
Debug.Log("LOL");
}
}
}