Repeat Button disappearing?

Im having an issue when i click the left button my right button will disappear until i unclick the left. But when i hit the right button my left button stays. Please help. Thank you.

        if (GUI.RepeatButton(new Rect(10,550,50,30),"Left")) {
          hAxis = -1;
        }
        else if (GUI.RepeatButton(new Rect(60,550,50,30),"Right")){
          hAxis = 1;
        }
        else {
          hAxis = 0;
        }

The ‘else’ after the Left button is what causes the Right button to disappear. That conditional basically is this:

  1. Show ‘Left’ button
  2. If ‘Left’ button is not pressed, show ‘Right’ button
  3. If ‘Right’ button is not pressed, hAxis is 0

Any time a condition is met, subsequent ‘else’ statements are not evaluated.

So an easy fix would be something like this

void OnGUI()
{
	// Set hAxis to zero to start with
	int hAxis = 0;

	if (GUI.RepeatButton(new Rect(10,550,50,30),"Left"))
	{
		hAxis = -1;
	}
	
	if (GUI.RepeatButton(new Rect(60,550,50,30),"Right"))
	{
		hAxis = 1;
	}

	// Do something with hAxis
	Debug.Log("Debug statements shouldn't go in Update functions, but the hAxis value is : " + hAxis);
}