GUILayout.Box Width control

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

The top-left of the screen is always (0,0).

Try using Gui.DrawTexture instead, as it lets you set the heights and widths however you need them.

You could also put DrawTexture inside one of your Layout-ed areas to keep it layouted.

Thank you
This is indeed what i was searching for.