whats wrong with this… it only works once bothways?
var index = 0;
var model: GameObject;
var animName: String[];
if (GUI.Button(Rect((Screen.width/2)+30,25,30,30),">"))
{
if (index < animName.Length)index ++;
model.animation.Play(animName[index]);
print(index);
print (animName[index]);
}
if (GUI.Button(Rect((Screen.width/2)-30,25,30,30),"<"))
{
if (index > animName.Length)index --;
model.animation.Play(animName[index]);
print(index);
print (animName[index]);
}
Yes the buttons are in OnGui
I moved the model.animation.play(animName[index]); outside the buttons and the index var outside the onGUI. Now it works.
I’m a selftought coder in progress so now i wonder what the difference is for the variable inside a function or outside. It seems that that was what made it work? I only use the var inside the same function i created it so i thought there was no need to set it on top with the rest.