GUILayout.Box controlling Width

I want to control the width of a GUILayout Texture2D.

GUILayout.Box(fuelBarTex, fuelBarStyle);

I tried to do this by GUILayout.Width;

GUILayout.Box(fuelBarTex, fuelBarStyle, GUILayout.Width(100));

But this also scales the hight even when i give a absolute hight with it.

GUILayout.Box(fuelBarTex, fuelBarStyle, GUILayout.Width(100), GUILayout.Height(100));

So maybe this can be done, but for some reason it's not.

i also tried this:

   var fuelBar: GUILayout;
   fuelBar =  GUILayout.Box(fuelBarTex, fuelBarStyle);
   fuelBar.width = 200;

that doesnt work either.

I cannot use GUI.Box because i want it to be in the top-left part of the screen, even if resized. can someone explain me what i'm doing worng?? Thanks

You can still use GUI.Box (or GUI.DrawTexture would be better) and have it scale to the screen resolution. Just do this:

function OnGUI(){
   GUI.DrawTexture(Rect(Screen.width*0.1,Screen.height*0.1,100,100),fuelBarTex);
}

This way the texture will always be 10% of the screen width across. You can use any kind of equation you want with Screen.width if that's not where you want it.

If you wanted it flush with the corner then it'd be Rect(0,0,100,100)