Problem is, the window will be correctly positioned only since the second time it’s drawn (because the first time the window rect has not yet been generated), and thus it will appear for an instant in an incorrect position.
Anyone knows a way to reposition a window AFTER GUILayout.Window has been called, but BEFORE it is actually drawn? I suppose this is not possible, but: any workarounds? Please note that I’m talking about liquid/GUILayout windows, where width and height is not known until they’re created.
Is it? Can you explain how is it a system hog? Also, a workaround I would do - I would draw the GUI on the first frame it pops up with Alpha set to zero.
Rationale: My guess is Unity doesn’t actually draw the Window, but manages its position in this call, while building a draw call list to be sent. Calling this again invalidates the list created previously for that window.
//if the button is pressed means if exists
if(GUI.Button(new Rect (Screen.width / 2-75,Screen.height / 2-160,30,30),sand))
{
}
// Make the second button
GUI.Button(new Rect (Screen.width / 2-45,Screen.height / 2-160,30,30),"");
}
}
Rationale: My guess is Unity doesn’t actually draw the Window, but manages its position in this call, while building a draw call list to be sent. Calling this again invalidates the list created previously for that window.
When you use “EditorGUILayout” inside your “WindowFunction”, this workaround will make all controll positions performed inside “WindowFunction” invalide. Therefore this solution is not valide for a proper functional gui extension.