Problem creating GUI.Window, Help please!

Hi i’m having some trouble while trying to use GUI.Window here’s my code:

 void OnGUI()
    {
        baulRect = GUI.Window(BAUL_WINDOW_ID, baulRect, WindowBaul(BAUL_WINDOW_ID), "Baul");
        caracteristicasRect = GUI.Window(CARACT_WINDOW_ID, caracteristicasRect, WindowCaract(CARACT_WINDOW_ID), "Caracteristicas");
   }

there’s the OnGUI function, now here are the two functions to draw the window.

private void WindowBaul(int id)
    {
        GUI.Label(new Rect(screenAncho * .5f, screenAlto * .15f, 100, 20), "Baul:");
    }

    private void WindowCaract(int id)
    {
        GUI.Label(new Rect(screenAncho * .76f, screenAlto * .15f, 100, 20), "Nombre:");
        GUI.Label(new Rect(screenAncho * .76f, screenAlto * .15f + 22, 100, 20), nombre);//Variable charProperties.Name.Trim()

        GUI.Label(new Rect(screenAncho * .76f, screenAlto * .15f + 44, 100, 20), "Velocidad:");
        GUI.Box(new Rect(screenAncho * .76f, screenAlto * .15f + 66, velocidad, 20), "");
        GUI.Label(new Rect(screenAncho * .76f, screenAlto * .15f + 88, 100, 20), "Fuerza:");
        GUI.Box(new Rect(screenAncho * .76f, screenAlto * .15f + 110, fuerza, 20), "");
        GUI.Label(new Rect(screenAncho * .76f, screenAlto * .15f + 132, 100, 20), "Turbo:");
        GUI.Box(new Rect(screenAncho * .76f, screenAlto * .15f + 154, turbo, 20), "");
    }

and here’s the error im getting by now.

error CS1502: The best overloaded method match for `UnityEngine.GUI.Window(int, UnityEngine.Rect, UnityEngine.GUI.WindowFunction, string)’ has some invalid arguments

error CS1503: Argument #3' cannot convert void’ expression to type `UnityEngine.GUI.WindowFunction’

error CS1502: The best overloaded method match for `UnityEngine.GUI.Window(int, UnityEngine.Rect, UnityEngine.GUI.WindowFunction, string)’ has some invalid arguments

error CS1503: Argument #3' cannot convert void’ expression to type `UnityEngine.GUI.WindowFunction’

Can any body tell me why is this happening? and dont say the obvious, I´ve already tried the documentation and some youtube tutorials, and every one is using the same thing as me!

Hi there,

You hint is here :

error CS1503: Argument #3’ cannot convert void’ expression to type `UnityEngine.GUI.WindowFunction’

In your code, you are actually invoking the WindowFunction, not passing it as a parameter. Since the function returns void, it tries to pass void to the GUI.Window method, and that’s what it’s complaining about.

Try this instead :

baulRect = GUI.Window(BAUL_WINDOW_ID, baulRect, WindowBaul, “Baul”);

See the third param, WindowBaul, passed as a function object, and not invoked (through the lack of () after the function).