Scroll backwards in Array

Hello,

lets say i have an Array of textures and i would like to go forward and backward while pressing a button. Forward option is working just fine but i cant do the backward scrolling.

Forward

if (i < texturesArray.Length-1) { 
       i++;
   	   }else {	    	
	    i = 0;
}

Backward

if (i < texturesArray.Length-2) {
       i++;
	   }else {
		    	
	   		i = 0;

Thank you

//Up Button
if(i < texturesArray.Length)
i++;
else
i = 0;

//Down Button
if(i > 0 && i < texturesArray.Length)
	i--;
else
	i = texturesArray.Length;

if (upButton)
i = (i+1) % texturesArray.Length;

if (downButton)
    i = Mathf.Repeat (i-1, texturesArray.Length);

this will probably be a bit akward code, but it’s working for me. I am using both answers build in one.

Up and Down button

 if (GUI.Button(new Rect(Screen.width * 0.75, Screen.height * 0.815, 100, 100)," Next Potion ")) {							
    	    	
        invertClickRight = true;
    	    	
    	    if (invertClickRight) {
    		    	i = (i+1) % potionsTextures.Length;
                }
 }


if (GUI.Button(new Rect(Screen.width / 4 - 100, Screen.height * 0.815, 100, 100)," Previous Potion ")) {
       	
	       	invertClickLeft = true;
	    	
	    	if (invertClickLeft ) {
		    	
		    	if (i > 0 && i < potionsTextures.Length) {																					    																																	
		    		i--;																										
		    	}else {																											
		    	
		    		i = potionsTextures.Length -1;  
		    	}
	    	}  
    	}