How can I put this function in GUI Window?

shopWindow = GUI.Window (0, shopWindow, DoMyWindow, “Shop”);

How do I put this function 

function ResizeGUI(_rect : Rect) : Rect
{
    var FilScreenWidth = _rect.width / 800;
    var rectWidth = FilScreenWidth * Screen.width;
    var FilScreenHeight = _rect.height / 600;
    var rectHeight = FilScreenHeight * Screen.height;
    var rectX = (_rect.x / 800) * Screen.width;
    var rectY = (_rect.y / 600) * Screen.height;
 
    return Rect(rectX,rectY,rectWidth,rectHeight);
}

Into the window script as I did with buttons:
if (GUI.Button(ResizeGUI(Rect (197,20,105,30)), "")) {

Your ResizeGUI function takes type Rect as a parameter as default values and returns a Rect, so you can supply this function as the rect parameter when using GUI.Window shopWindow = GUI.Window(0, ResizeGUI(shopWindow), DoMyWindow, "Shop");

If I do that, it makes it go beserk, resizing every frame and dissapear

1 Answer

1

Have you tried this

if( resizeWindow ) 
{
    shopWindow = ResizeGUI( shopWindow );
    resizeWindow = false;
}
shopWindow = GUI.Window( 0, shopWindow, DoMyWindow, "Shop" );

I thought that at first but setting shopWindow to it will cause shopWindows values to be divided every time, causing it to screw up horribly

Thanks Josh707, yes you are right. Excalibera resize window only when you need it to be resized.

I need it to be resized automaticly, that's the problem :/

There must be a reason why you need to resize window? Check your logic, you will find it.

I'm not getting what you mean, I have no idea how to put this into a window :/. I need to resize the window, because it's a web player, and every player has a different screen dimension, so it has to resize itself, since the webplayer is set to fill the whole browser window.