Search Unity

How to quit or unload UnityPlayer without killing overall process?

Discussion in 'Android' started by JessHolle, Aug 15, 2020.

  1. JessHolle

    JessHolle

    Joined:
    Jul 9, 2019
    Posts:
    14
    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.
     
  2. chris_unity549

    chris_unity549

    Joined:
    Aug 28, 2020
    Posts:
    7
    dimitris_baud likes this.
  3. chankeiro

    chankeiro

    Joined:
    Oct 25, 2021
    Posts:
    11
  4. ngthlong1990

    ngthlong1990

    Joined:
    May 5, 2022
    Posts:
    3
    I also hope this is solvable
     
  5. dhuria007

    dhuria007

    Joined:
    Oct 23, 2023
    Posts:
    1
    @JessHolle did you manage to solve this?