- Home /
GUI.Window Set pos after runtime
So I am running into a problem where I cannot set the position of a window after I have ran the program. I have tried delcaring it in the OnGUI function, but then it is static and not draggable (probally somthing to do with that) but just wondering if anyone knows how to set a GUI.Window to select X, Y.
var screenX : int;
var screenY : int;
var windowRect0 : Rect = new Rect(screenX, screenY, 100, 100);
function OnGUI () {
screenX = Screen.width*2/3;
screenY = Screen.height/2;
Debug.Log(windowRect0);
windowRect0 = GUI.Window (0, windowRect0, DoMyWindow, "Inventory");
But it is spawning at 0, 0, top left no matter what i change in the script. And if I put the var in the OnGUI function I cannot drag it.
You never write the screenX
and screenY
into your windowRect0
. I know your line 3 kinda does this, but at this line the two variables haven't been set. I guess you assume the compiler will spot when you edit a variable and apply the change for you. Compilers don't do that.
Right I know its not being set becuase it has nothing to set with until compile.