GUI.Window only shows for one frame under all circumstances

Okay, this is really starting to annoy me as I’ve tried to fix it for over a week now and the internet doesn’t help at all because people keep asking this question saying that they put the window call in a GUI.Button statement.

GUI.Window will NOT render for me even if I put it under the OnGUI function with nothing else in there.

I’ve tried GUI.Window and GUI.ModalWindow (which is what I’m aiming to do).

Please help me fix this, I’ve also tried putting it in multiple different scripts and it will not work, here’s something similar to what I’m doing:

function OnGUI(){
   GUI.Window(0, Rect(0, 0, 1920, 950), StupidAssWindow, "The non-renderer");

function StupidAssWindow(id : int){
  print("I don't ever print to the console");

That’s not the exact code I use but I only have different names set, this won’t work. Please help me.

And if you can find the fix in C# I can understand C# nearly as well as JS so I can translate it fine.

I just tried your exact example code and it works as expected. I get an empty window that covers the whole screen and each frame i get two times the line “I don’t ever print to the console” …

I could have told that without even trying but i just want to be sure as i never use UnityScript.

So if it doesn’t work for you, there must be something else going on. Are you sure your script is enabled and doesn’t get disabled be some other script? Same for the gameobject it’s attached to. Maybe you disable or destroy the gameobject somewhere?

Try adding:

function Update() {
    print("Update, yeah");

and see if that prints. If not your script is most likely not enabled or not there anymore.


As i already wrote in the comment below (which got burried under several other comments) the reason why your GUI.Window doesn’t work is because you disabled the Layout event.

See the documentation for more details:

if MonoBehaviour.useGUILayout is set
to false then a call to GUI.Window
will not have any effect, even though
it is not a GUILayout function.

After over two weeks I finally figured it out! I feel like such a dumbass now,


I don’t even know what that statement does but it was in my script and that’s what caused it to not work. Thank you everyone for your help, without you I wouldn’t have looked at that line of code.