- Home /
Question by
NickCh · Dec 27, 2010 at 11:46 AM ·
guiguitextureswitchreturn
How to return from the last case to the first
The whole thing is that i want to make a reload code for my ammo.
Example Code
var ammo1:GUITexture; var ammo2:GUITexture; var ammo3:GUITexture; var AMMO = 3
function FixedUpdate()
{
switch(AMMO)
{
case 1:
guiTexture.texture = ammo1;
break;
}
case 2:
guiTexture.texture = ammo2;
break;
}
case 3:
guiTexture.texture = ammo3;
break;
case 4:
//return to case 1. break; } if(Input.GetButton("Fire1") ScriptName.AMMO -= 1; }
Comment
Best Answer
Answer by Jesus_Freak · Dec 27, 2010 at 03:54 PM
U could make the last case = the first one ie:
case 4:
AMMO = 1;
break;
Or replace 4 with 0 since u run OUT of ammo.
Yess thanks! Fool me i have tried it but ins$$anonymous$$d of 1 i wrote 0...FOOL $$anonymous$$E!!!
Your answer
![](https://koobas.hobune.stream/wayback/20220613092708im_/https://answers.unity.com/themes/thub/images/avi.jpg)