- Home /
Unity3D WWW call on main thread on iOS
In the game we're making, we want to do attempt a remote user save data when the app suspends. In Unity's Editor, and on Android, this is as simple as
WWW www = new WWW(_URL);
while(!www.isDone)
{
Thread.Sleep(100);
}
Debug.Log(www.text);
(full sample: https://github.com/SixMinute/iOSWWWGet)
But on iOS, www.isDone
never evaluates to true while we're blocking, so the whole thing just hangs.
Is this a bug, or by design? And then if it's by design, what's the proper way to do it, because if put this behind a StartCoroutine
, it's not properly on the main thread, and on suspend, what's happening gets pushed to when the app resumes (which completely defeats the purpose of what we're trying to do).
Comment