I making a gui animation. I have a four Texture2D , looping this textures. This Script Loop and stoping Unity3d.
var num:int=0;
function Update () {
while (num<=4) {
num++;
Debug.Log(num);
if(num==4){
num=0;
}
}
}
I making a gui animation. I have a four Texture2D , looping this textures. This Script Loop and stoping Unity3d.
var num:int=0;
function Update () {
while (num<=4) {
num++;
Debug.Log(num);
if(num==4){
num=0;
}
}
}
Maybe you shouldnt use a while loop. Just a if statement. The Update() is pretty much a loop in its own if you manipulate it properly. So try:
function Update(){
if(num <= 4){
num++;
if(num >= 4)
num = 0;
}
}
With this, it will increment the variable as long as the if statement is true and may not crash your game.