GUI.Button & else if problem

Hi,

I’m having a bit of problem finding out what is wrong with the following control.

What I am trying to accomplish is making navigational buttons which gets active if a valid direction move exist to either N, NE, E, SE, S, SW, W, NW and inactive when not present.

It works perfectly fine, but the issue is when I reach edges of map, the button disappears and then when I move away from edge it comes back…

I know it because List.Contains evaluates false when edge is reached, question is how would draw the button even so :slight_smile:

if(movement.pathList.Contains(GameObject.Find("G" + (movement.gridNumber + 1) + " (m" + map.mapNumber + ")").transform) && (movement.yPos % 2 == 1)) {
			if(GUI.Button(new Rect(112, 148, but_Width, but_Height), "", nav_SE_Active))
				movement.gridNumber += 1;
		}
		else if(movement.pathList.Contains(GameObject.Find("G" + (movement.gridNumber + 33) + " (m" + map.mapNumber + ")").transform)) {
			if(GUI.Button(new Rect(112, 148, but_Width, but_Height), "", nav_SE_Active))
				movement.gridNumber += 33;
		}
		else
			GUI.Button(new Rect(112, 148, but_Width, but_Height), "", nav_SE_Inactive);

If you don’t call GUI.Button, then no button will be drawn. You can do something like this:

GUI.enabled = movement.pathList.Contains(GameObject.Find("G" + (movement.gridNumber + 1) + " (m" + map.mapNumber + ")").transform) && (movement.yPos % 2 == 1)
if(GUI.Button(new Rect(112, 148, but_Width, but_Height), "", nav_SE_Active)) {
            movement.gridNumber += 1;
}