wierd infinite while loop

I’m trying to find a dynamic amount of objects with the renderer mesh disabled, but the while loop I made make unity crashes.

Can someone explain me why?

int AnotherNumber()
int i;

			i =  Random.Range(0, iCounter);

			if(Lasers*.GetComponent<MeshRenderer>().enabled == false)*
  •  	{*
  •  		Debug.Log("is disable");*
  •  		break;*
  •  	}*
  •  	else*
  •  	{*
  •  		Debug.Log("is enabled");*
  •  	}*
  •  }*
  •  Debug.Log(i);*
  •  return i;*
  • }*

You wrote an infinite loop, where the only break condition is if at least one of the mesh renderer components in an array is disabled. If none of them are, then the loop will never end, which is definitely the kind of logic you never want to use. Instead of “while(true)”, use some kind of condition that will always cause the loop to end.