So i was writing a automated terrain colorizer when i noticed something strange. in my script i have 3 for loops. the 2 first goes from 0 to 1024 for the x and y values of the terrain. while the last for loop is for every texture i want to paint with. This runs fine. However, when i add a IF- statement underneath and it returns true, Unity freezes and refuses to respond. while the if statement returns false, the program runs fine…
after many attempts i decided to see if i could replicate the problem in a new project. so i wrote this wich also crashes try for yourself (put the script on any gameobject and set the variables to true when you press play) :
using UnityEngine;
using System.Collections;
public class ProblemCodeClass : MonoBehaviour {
public bool run = true;
public bool theProblem = true;
void Update () {
if (run){
for(int x = 0; x < 1024; x++) {
for (int y = 0; y < 1024; y++) {
for (int z = 0; z < 4; z++) {
Debug.Log("I run this fine");
if (theProblem){
Debug.Log("Im not getting here....");
}
}
}
}
run = false;
}
}
}
Any ideas why or how this can be fixed?