I am using the While loop in the Start method. The code is as following:
for (int i = 0; i < instPointsLength; i++)
{
int ranObj = Random.Range(0, ListLength);
do
{
ranObj = Random.Range(0, ListLength);
Debug.Log(ranObj);
}
while (usedLocation.Contains(streetList[ranObj]) == true);
instPointsList*.transform.position = streetList[ranObj].transform.position;*
usedLocation.Add(streetList[ranObj]);
}
Can anyone please help me out, why Unity is freezing, maybe because it becomes an Infinity Loop, but I can’t find it out how?
Because the list is empty for the first FOR loop iteration, the while loop will get a false and break, and similarly, for further iterations, it should break. Am I missing something, please let me know? Thanks a lot in advance.