GUI.Button flipped not working

i have a 6 button with image of a rocket assigned to them, on my main screen i need alternate buttons to point different direction[image of rocket]. so i came up with the the following

GUI.Button(new Rect(posX,posY,Scalex,ScaleY),"PLAY",m_GuiSkin.customStyles[2]) ;
GUI.Button(new Rect(posX,posY,-Scalex,ScaleY,"settings",m_GuiSkin.customStyles[2]) ;

But the button 2 dose not take click or hover…

				if(GUI.Button(new Rect(Screen.width * (0.84f/6.55f),Screen.height * (1.54f/6.3f),
							Screen.width * (3.744f/6.55f),Screen.height * (0.5967f/6.3f)),"SETTINGS",m_GuiSkin.customStyles[2]) )
				    m_Gamestate = GameState.Settings;
				if(GUI.Button(new Rect(Screen.width * (0.84f/6.55f),Screen.height * (2.28f/6.3f),
							-Screen.width * (3.744f/6.55f),Screen.height * (0.5967f/6.3f)),"HIGHSCORE",m_GuiSkin.customStyles[2]) )
				   m_Gamestate = GameState.HighScore;

A negative scale does not work the way you might expect it. All mouse events will fail because the rect has a negative size.

Rect.Contains is defined like this:

public bool Contains(Vector3 point)
    return point.x >= this.xMin && point.x < this.xMax && point.y >= this.yMin && point.y < this.yMax;

and xMax is defined like this:

public float xMax
        return this.m_Width + this.m_XMin;

So when you have a Width smaller than 0 Rect.Contains will always return false and therefor can never detect hover / click / …

A Rect should never be used with a negative size.

You have two possibilities:

  • draw the button manually which means you have to handle the click yourself.
  • Use two textures, and one inverted.

As a final note: You really should use the style names instead of using indices into the customStyles array:

void OnGUI()
{ = m_GuiSkin;
// […]
GUI.Button(new Rect(posX,posY,Scalex,ScaleY), “PLAY”, “MyButtonStyleName”);