Search Unity

My loop inside loop only run once

Discussion in 'Scripting' started by xskyhigh12, May 27, 2019.

  1. xskyhigh12

    xskyhigh12

    Joined:
    Nov 18, 2018
    Posts:
    14
    Code (CSharp):
    1. int i = 0;
    2.         while (i =< 4)
    3.         {
    4.             print("i = " + i);
    5.  
    6.             int u = 0;
    7.             while (u <= 4)
    8.             {
    9.                 print("u = " + u);
    10.  
    11.                 u++;
    12.             }
    13.  
    14.             i++;
    15.         }
    The code is inside Start(). And I don't have any global variables

    This should print out
    i=0
    u=0
    u=1
    u=2
    u=3
    u=4
    i=1
    u=0
    u=1
    u=2
    u=3
    u=4

    and so on, but it doesn't.

    upload_2019-5-27_22-1-28.png
    My version is Unity 2019.1.1f1 Personal. It works for my other friends that use Unity, but they have the 2018 version
     
  2. adibichea

    adibichea

    Joined:
    Jul 15, 2015
    Posts:
    73
    I have 2019.1.4f1 and works for me

    Also, i see that you have "collapse".. activated
     
    xskyhigh12 likes this.
  3. xskyhigh12

    xskyhigh12

    Joined:
    Nov 18, 2018
    Posts:
    14
    Wow do i feel stupid now
     
  4. adibichea

    adibichea

    Joined:
    Jul 15, 2015
    Posts:
    73
    Meh! I've noticed because this happened also to me (many times) :)