Positioning GUI Texture

I’m having problem resizing the Textures. And I need the textures to be in exact position no matter the Screen Aspect Ratio, Resolution. Here’s a layout of what I need. How to do it through coding and I’ve attached my current code.

Code :

var playImage : Texture;
var optionImage : Texture;
var exitImage : Texture;

var myStyle : GUIStyle;

function OnGUI ()
{
    if(GUI.Button(Rect(Screen.width/2, Screen.height/2, 190, 40), playImage))
    {
        Debug.Log("works!");
    }
  
    if(GUI.Button(Rect(Screen.width/2, Screen.height/2, 190, 40), optionImage))
    {
        Debug.Log("works!");
    }
  
    if(GUI.Button(Rect(Screen.width/2, Screen.height/2, 190, 40), exitImage))
    {
        Debug.Log("works!");
    }
}

Have you tried wrapping the Screen.width/2 in a mathf function to round it off to an integer?

Mathf.Floor(Screen.width/2)

@monark : Can you show me a sample code line?

  • if(GUI.Button(Rect(Mathf.Floor(Screen.width/2), Mathf.Floor(Screen.height/2), 190, 40), playImage))
  • {
  • Debug.Log(“works!”);
  • }

Thanks. I’ll try it let ya know.