I have an editor script that generates a random level, I have a for loop that checks for duplicates of certain objects and is supposed to reset and check if it finds one but it keeps crashing and freezing unity. What is wrong with my loop?
private int CheckForMultiple(int testBuilding, int roomIndex)
{
int newBuilding = testBuilding;
for(int i = 1; i < roomIndex; i++)
{
if(_indexes[i] == newBuilding)
{
newBuilding = (int)Random.Range(0, backgroundElements.Count);
i = 1;//reset loop and start over
}
}
return newBuilding;
}
↧