|
I got a function called Spin() that is called when a user press a button drawn on OnGUI(). That function, at some point, says something like this: The things is that when Unity is waiting for query, the GUI disappears. If if comment that line, the GUI shows perfectly. How I need to write my code in order to have the GUI showing correctly and still wait for the query result? EDIT: The code is from the function Spin() that's called on OnGUI();
(comments are locked)
|
|
Because the query part is asynchronous, you need to make sure that gets split off into a separate Coroutine, instead of forcing the GUI to wait for it to finish. Keep a boolean variable outside of both functions, that takes care of the yield timing: This prevents to blink, but the game crashes... May by there're 2 different issues! I'll work on that, thanks!! :)
May 16 '12 at 01:05 PM
DarkSlash
The only thing I can think of is that you're doing something with the query's result in the GUI loop. But maybe the modification happens whilst the GUI is running, between two EventTypes. Try to commit the modification after a WaitForEndOfFrame() ?
May 16 '12 at 02:49 PM
Berenger
(comments are locked)
|

could you write your OnGUI function and Spin function (only the relevant parts) ?
It's really extensive, like 500 lines... I think the important part is
function OnGUI() { Interface(); }
funcion Interface() { if(GUI.Button(something)) { Spin(); } }
function Spin() { var url : String = "mysampleurl";
var query : WWW = new WWW (url);
yield query; do something else; }
That's the basic! :)