How to quit or unload UnityPlayer without killing overall process?

Embedding Unity as an Android library, we are struggling to find any way to quit or unload the UnityPlayer without Unity killing the overall process.

We simply want to be able to do UnityPlayerActivity.finish() to return to the previous Activity. Whatever we do seems to result in Unity exiting the overall process.

Overriding UnityPlayerActivity’s onUnityPlayerUnloaded and onUnityPlayerQuitted (the latter of which does a Process.kill on the process!) to be no-ops does not help.

Overriding UnityPlayerActivity.finish() to call mUnityPlayer.quit() prior to super.finish() helps from a user perspective – because the process is killed while the UnityPlayerActivity subclass is still the current Activity – so Android restores the process with the next Activity on the stack as the current. So this visually looks almost right – but it’s a slower, rougher transition than it should be and all non-persistent state process state is obviously lost.

This seems like a very serious impediment to Unity embedding. I see references to simliar issues on the forums over time, but I do not see definitive answers or “it’s been fixed” responses.

We are currently at Unity 2019.4.3f1.

3 Likes

Hey @JessHolle , did you find a solution to this after all? We are having the same issue Unity as a Library - Unload and Activities Stack

1 Like

Hi @JessHolle , @chris_unity549 , I am having the same problem. Did you manage to solve it?

I also hope this is solvable

@JessHolle did you manage to solve this?