I have a question about how unity executes c# plugins. I am calling 3 native functions in my script. The other two cannot be called until the first one has finished executing. The first function pauses unity (using stinkbot unity pause); yet the other two are called before it has a chance to finish.
Does unity finish its frame before calling the external functions? Any info would be great. Thanks
Unity execution is essentially put on hold while the plug-in code executes.
Hmmm…thats strange then I wonder why my other plugins execute. Oh well cheers for the heads up at least I know it’s something I am doing.
Unity automatically unpauses when the app receives an applicationDidBecomeActive message. iPhoneOS sends applicationDidBecomeActive at all kinds of inconvenient times, like when a pop-up dialog is closed.
Basically you should have a test that prevents Unity from unpausing until you’re ready.
- (void) applicationDidBecomeActive:(UIApplication*)application
{
printf_console("-> applicationDidBecomeActive()\n");
if (PLUGIN_DONE) {
UnitySetAudioSessionActive(true);
UnityPause(false);
}
}
Hi,
please keep in mind that UnityPause works with 1 frame lag, so it will effective only when current frame processing finishes.