Home > database >  Unload & quit Unity from an external iOS App
Unload & quit Unity from an external iOS App

Time:10-16

I implemented a Unity Project using the "Unity as a Library" feature into my existing iOS app. I want to unload and quit it when I press a button to return to my existing app.

I'm currently using the "unloadApplication" method of the UnityFramework class to unload Unity. However, this method does not completely quit the Unity application and returns to the existing app. After executed, the UIWindow created by the Unity Framework containing the game is frozen. I'm then hiding the UIWindow and unhiding it opening Unity again. Since I want to completely quit and restart Unity this doesn't work. As stated in the Unity documentation the UnityFramework class also provides a "quitApplication:(int)exitCode" method but this one kills Unity and my existing app.

The "quitApplication" method description says:

Call this to unload Unity completely and receive a callback to UnityFrameworkListener when Unity quits. Unity will release all memory.

Note: You won’t be able to run Unity again in the same process after this call. You can set quitHandler on AppController to override the default process kill.

Is there a way to completely quit the Unity application, return to my existing app and be able to start Unity again later on?

CodePudding user response:

When using the "Unity as a Library" Feature to integrate Unity into your native iOS application you won't be able to fully terminate Unity and return to your native App.

As stated in the Unity Documentation on integrating Unity into native iOS applications you are able to call the method - (void)unloadApplication; on the UnityFramework instance to release most of the memory it occupies, but not all of it. You will be able to run Unity again after doing so.

  • Related