loop for OnClick Button

it’s the code,

                      public int a=0;
                         if(int a<=5){


if I put it in the update function it works fine and shows [0,1,2,3,4,5] , but I want to use this code as On Click button. but this case it only shows in console [0] ,is there any way to when I Click On the button it shows [0,1,2,3,4,5] ?

Hi men, you need to use ‘for’ like this to do what you want not ‘if’ statement :

for (int i = 0; i <= 5; i++)

I hope I help, Sean.