|
Hello, I need to have a GUILayout Window appear at the exact center of the screen, and I'm using this (where winRect is a stored Rect variable): 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. Thanks for any help :)
(comments are locked)
|
|
Calling `GUILayout.Window` again repositions the window without any flicker, nor extra draw calls. 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. I like this one even more! Marked :)
Dec 07 '12 at 09:19 PM
Izitmee
(comments are locked)
|
|
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. Smart workaround. If you write it as a complete answer, I will vote it as the correct one :) About Unity GUI being a system hog, you can check anywhere on the internet, since everybody agrees: especially for mobile development it is definitely un-performant.
Dec 07 '12 at 08:53 PM
Izitmee
P.S. ah, never realized there was a "convert comment to answer" button :P
Dec 07 '12 at 09:25 PM
Izitmee
(comments are locked)
|

Good question - I'm dealing with exactly the same problem at the moment. I'd upvote if I could.
Personally, I didn't find a solution, and since then stopped using Unity's GUI (which anyway is a system hog) :P
I've got an answer to this question, although I'd like to ask what did you switch to? NGUI?
I heard lots of good stuff about NGUI, so I'd recommend it even if I never used it (alos, its developer was just hired by Unity to work on the new version of Unity GUI). Personally, since I have and love 2D Toolkit, I built a framework to easily use it also for the GUI (by the way, I'm remaking it from scratch and posted it on Google Code among my HOUnityLibs, in case you're interested - though for now it's good only for buttons: http://code.google.com/p/hounitylibs/).