- Home /
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), Do$$anonymous$$yWindow, "Shop");
If I do that, it makes it go beserk, resizing every frame and dissapear
Answer by Sundar · Dec 12, 2013 at 06:53 PM
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.
Your answer
Follow this Question
Related Questions
Help Changing GUI Text size 0 Answers
How can I resize an image with drag-and-drop? 1 Answer
GUI.Window called 2 frames ahead than OnGUI? 0 Answers
What is the best way to resize textures on the GUI? 3 Answers