This question was 
             closed Apr 18, 2020 at 12:37 PM by 
             creeper09. 
            
 
            Why Unity hang when my if statement fail
Hello, I have a problem, I am making a level generator that generates a branch of rooms. In one of my tests I discovered that there was a chance that several rooms could overlap with other rooms. So after a little bit of google research I did this :
 void GenerateBranch()
     {
         int i = 0;
 
         while (i < branchLength)
         {
             // We make sure that the room is not overlapping another one.
             if (!groupPos.Contains(new Vector2(currentPosX, currentPosY)))
             {
                 groupPos.Add(new Vector2(currentPosX, currentPosY));
                 // the generation process is normally here but I don't show you it because it is too long
                 i++;
             }
             else
             {
                 Debug.Log("The level generation was creating room over the other one, we stopped this action");
                 i--;
             }
         }
     }
the program is working fine but when the program detects that a room is going to overlap another one Unity freezes.
               Comment
              
 
               
               koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                