How to Control GUILayout.Window's Size

Hello,everyone. I wanna to draw a window with some other controls in it using GUILayout.Window, But i can not control the window’s size, for it is a little small for my application after GUILayout calculate its size, Here is part of the code:

public int _wndWidth = 450;
public int _wndHeight = 420;
private Rect _rectWnd;

void Start()
{
    _rectWnd = new Rect(Screen.width * 0.5f - _wndWidth * 0.5f, Screen.height * 0.5f - _wndHeight * 0.5f, _wndWidth, _wndHeight);
   
}

void OnGUI
{
        _rectWnd = GUILayout.Window(GlobalGUIWindowId._WND1_YXY, _rectWnd, ShowParamsWnd, _wndTitle, _guiSkin.window, GUILayout.MinWidth(_wndWidth), GUILayout.MinHeight(_wndHeight));
}
private void ShowParamsWnd(int id)
{
   //some other controls.
}

the final effect is below:

125alt text125

How to control the window’s size, i want to enlarge it. Thanks in advance!

2 Answers

2

Use GUILayout options, ex: http://unity3d.com/support/documentation/ScriptReference/GUILayout.Width.html

The last example on this page uses it. You can also play with height. http://unity3d.com/support/documentation/ScriptReference/GUILayout.Window.html

Lastly, you can adjust the Rect that comes back from the GUILayout.window call directly.

Cool, didn't realise GUILayoutOptions were also possible for Windows. I always directly altered the returned Rect.

Thank you, the problem have gone, i find that there is noting wrong with my code after i post this question. The reason is that i haven’t change the two variables’value on the inspector,
public int _wndWidth = 450;
public int _wndHeight = 420;

It still stay 300 and 200 if i do not change it on the inspector, thanks any way.