Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)applicationDidEnterBackground:(UIApplication*)application
- {
- ::printf("-> applicationDidEnterBackground()\n");
- if(_unityAppReady)
- {
- UnitySetPlayerFocus(0);
- _wasPausedExternal = UnityIsPaused();
- if (_wasPausedExternal == false)
- {
- // do pause unity only if we dont need special background processing
- // otherwise batched player loop can be called to run user scripts
- int bgBehavior = UnityGetAppBackgroundBehavior();
- if(bgBehavior == appbgSuspend || bgBehavior == appbgExit)
- {
- // Force player to do one more frame, so scripts get a chance to render custom screen for minimized app in task manager.
- // NB: UnityWillPause will schedule OnApplicationPause message, which will be sent normally inside repaint (unity player loop)
- // NB: We will actually pause after the loop (when calling UnityPause).
- UnityWillPause();
- [self repaint];
- UnityPause(1);
- // this is done on the next frame so that
- // in the case where unity is paused while going
- // into the background and an input is deactivated
- // we don't mess with the view hierarchy while taking
- // a view snapshot (case 760747).
- dispatch_async(dispatch_get_main_queue(), ^{
- _snapshotView = [self createSnapshotView];
- if(_snapshotView)
- [_rootView addSubview:_snapshotView];
- });
- }
- //Periodically force Unity to run the update loop while going to the background
- [UnityiOSForcedUpdater startBackgroundUpdateTimer];
- }
- }
- _didResignActive = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement