Using Controller Input / Script goes to last function

Hello all,

It seems like lately the holy grail for my project is finding a way to scroll through a menu with a gamepad. In trying to learn how to do this I wrote up a very simple script, as a means of trying to learn how to do this, one that to these noob’s eyes looks like it should work.

And of course, it doesn’t. Actually, not only doesn’t it work, but in the five functions available, the script always and immediately goes straight for the last one. I know I’ve done something (lots of things?) wrong, and am hoping that someone might be able to point me in the write direction. Thanks, and God bless.

var inventoryText : GameObject;// this is a selection of GUIText objects
var inventoryText2 : GameObject;
var inventoryText3 : GameObject;
var inventoryText4 : GameObject;
var inventoryText5 : GameObject;


function Start (){
inventoryText.guiText.material.color = Color.green;
inventoryText2.guiText.material.color = Color.white;
inventoryText3.guiText.material.color = Color.white;
inventoryText4.guiText.material.color = Color.white;
inventoryText5.guiText.material.color = Color.white;
	if(Input.GetAxis("Vertical")){
		nextstep ();
		
}
}

function nextstep (){
inventoryText.guiText.material.color = Color.white;
inventoryText2.guiText.material.color = Color.green;
inventoryText3.guiText.material.color = Color.white;
inventoryText4.guiText.material.color = Color.white;
inventoryText5.guiText.material.color = Color.white;
	if(Input.GetAxis("Vertical")){
		nextstep2 ();
	}
}

function nextstep2 (){
inventoryText.guiText.material.color = Color.white;
inventoryText2.guiText.material.color = Color.white;
inventoryText3.guiText.material.color = Color.green;
inventoryText4.guiText.material.color = Color.white;
inventoryText5.guiText.material.color = Color.white;
	if(Input.GetAxis("Vertical")){
		nextstep3 ();
	}
}

function nextstep3 (){
inventoryText.guiText.material.color = Color.white;
inventoryText2.guiText.material.color = Color.white;
inventoryText3.guiText.material.color = Color.white;
inventoryText4.guiText.material.color = Color.green;
inventoryText5.guiText.material.color = Color.white;
	if(Input.GetAxis("Vertical")){
		nextstep4 ();
	}
}

function nextstep4 (){
inventoryText.guiText.material.color = Color.white;
inventoryText2.guiText.material.color = Color.white;
inventoryText3.guiText.material.color = Color.white;
inventoryText4.guiText.material.color = Color.white;
inventoryText5.guiText.material.color = Color.green;
	//if(Input.GetAxis("Vertical")){
		//nextstep ();
	//}
}

Note: If I uncomment the last two lines, the code DOES send me back to function nextstep, but still can’t use the controller to move through the selections.

var inventoryText : GameObject;// this is a selection of GUIText objects
var inventoryText2 : GameObject;
var inventoryText3 : GameObject;
var inventoryText4 : GameObject;
var inventoryText5 : GameObject;
var menu:int=0;

    function FixedUpdate(){
	        if(Input.GetButtonDown("Vertical")){
			if(menu==0){
			print("0");
    inventoryText.guiText.material.color = Color.green;
    inventoryText2.guiText.material.color = Color.white;
    inventoryText3.guiText.material.color = Color.white;
    inventoryText4.guiText.material.color = Color.white;
    inventoryText5.guiText.material.color = Color.white;
     
    }
		else	if(menu==1){

  inventoryText.guiText.material.color = Color.white;
    inventoryText2.guiText.material.color = Color.green;
    inventoryText3.guiText.material.color = Color.white;
    inventoryText4.guiText.material.color = Color.white;
    inventoryText5.guiText.material.color = Color.white;
        }

		else	if(menu==2){
  inventoryText.guiText.material.color = Color.white;
    inventoryText2.guiText.material.color = Color.white;
    inventoryText3.guiText.material.color = Color.green;
    inventoryText4.guiText.material.color = Color.white;
    inventoryText5.guiText.material.color = Color.white;
        }

		else	if(menu==3){
 inventoryText.guiText.material.color = Color.white;
    inventoryText2.guiText.material.color = Color.white;
    inventoryText3.guiText.material.color = Color.white;
    inventoryText4.guiText.material.color = Color.green;
    inventoryText5.guiText.material.color = Color.white;
        }
		else	if(menu==4){

    inventoryText.guiText.material.color = Color.white;
    inventoryText2.guiText.material.color = Color.white;
    inventoryText3.guiText.material.color = Color.white;
    inventoryText4.guiText.material.color = Color.white;
    inventoryText5.guiText.material.color = Color.green;
        menu=-1;
    }
	            menu++;

	}
	}

If f1 calls f2, then f3, then f4, then f1, again, and over and over again, you can’t use the controller because you’re caught in an endless “loop”.