Cycling Images...

I’m currently stuck trying to cycle images. I’m attempting to get so every time I press the mouse button it moves to the next “image”. I tried doing…

function OnMouseDown(){
	if (Input.GetMouseButtonDown(1));
	guiTexture.texture = form2;
	
	if (Input.GetMouseButtonDown(2));
	guiTexture.texture = form3;
}

but it didn’t really seem to work… It’ll work when it’s one but not two. I’ve tried a few different things and read plenty of posts but I couldn’t seem to find anything that worked for what I’m aiming to do.

A example…

picture 1, picture 2, picture 3
mouse click 1 (loads picture 1), mouse click 2 (loads picture 2), mouse click 3 (loads picture 3), mouse click 4 (loads picture 1) and keeps letting you cycle.

Thanks in advance.

I’m quite sure you misunderstood the documentation about the mouse button HERE.

What I think you need is :

private var counter:int = 1;

function OnMouseDown(){
    switch (counter)
    {
        case 1:
            guiTexture.texture = form2;
            break;
        case 2:
            guiTexture.texture = form3;
            break;
        case 3:
            guiTexture.texture = form4;
            break;
        case 4:
            guiTexture.texture = form1;
            break;
    }
    ++counter;
    if (counter == 5) counter = 0;
}

You can also simplify this code with a list of textures, and acces to the right one with myTexturesList[counter].

I’m trying to do something similar but am working in C#. I’m still fairly new to programming can someone please translate?