I would like to make a button with a relative size depending on the screen size. For all screens, I want my button to start at 20% from the left (of the screen size) and end 20% from the right of the screen size. My texture is 700x400 and does not fit within the bounds of the button on small displays. The below code is what I have at the moment, but it is not working as I want it.
GUI.contentColor = Color.white;
if (GUI.Button (new Rect (
(float)(Screen.width*0.2), // start at 20% of the screen width
(float)(Screen.height*0.3), // start at 30% of the screen height
(float)(Screen.width*0.8), // end at 80% of the screen width
(float)(Screen.height*0.5)), startTexture) // end at 50% of the screen height
) {
Application.LoadLevel ("MyOtherScene");
}
How can I make the texture to exactly fit the bounds of my button regardless of the display size?