Change GUI.Button Texture on runtime

I want to change the texture of a button depending of the value of a variable:

				textureA = optionAActive;
				textureB = optionB;
				textureA = optionA;
				textureB = optionBActive;

			if(GUI.Button(optionAPos,textureA)) { doubleTries--; }
			if(GUI.Button(optionBPos,textureB)) { doubleTries--; }

That’s is inside OnGUI. Then I have the function DoublePrize with this code:

IEnumerator DoublePrize()
	while(doubleTries > 0)
		doubleOptionA = !doubleOptionA;
		yield return new WaitForSeconds(1f);


I use Debug.Log to see if doubleOptionA is changing (I use it both on OnGUI and on DoublePrize()) and is changing good! What not is changing is the textures! I see always textureA = optionA and textureB = optionBActive. What I’m doing wrong?

**EDIT: ** I was calling DoublePrize() from GUI! So the variable doubleOptionA was switching from true to false so fast that it seems to be always in the same state! I solve that an the problem is gone! :slight_smile:

Your GUI.Button code is only looking for a ‘press’, you need to wrap those in another if that shows one or other based on your conditional