Search Unity

Running in background

Discussion in 'Android' started by mdeletrain, Jul 21, 2014.

  1. mdeletrain

    mdeletrain

    Joined:
    Jun 8, 2011
    Posts:
    47
    Hi all !

    I'm currently building an Android + Unity based solution for my customer and I'm facing some trouble since I updated from Unity 4.2.2 to Unity 4.5.2 (I also tried with Unity 4.3.4 and the problem is still here) :

    I have Unity applications automatically started from a custom loader. This loader displays a customized dynamic loading screen above Unity while it loads.

    This was working fine with applications build from Unity 4.2.2 but it seems all subsequent versions of Unity enter a somewhat paused state after waking up, waiting to be foremost before doing anything else. Obviously, since the scene is never loaded, the custom loading screen never disappear...

    I overridden Unity's java activity to see what happens and indeed everything loads fine from here... except the main scene is not loaded until I manually kill the custom loading screen. Then Unity wake's up and everything works fine again.
    I tried to force the onFocusChanged callback to always pass true to its super class whatever it receives, but that does not work since the activity never goes into this method.

    I tried to force the "Run in background" setting to true in player's settings but as expected it did not work, since it is only available in Web, OsX, Windows and BlackBerry devices.

    Does anyone have any idea how I could force Unity to load the main scene and at least render its first frame ?

    If that helps, everything is run from an Android 4.2.2 device.
     
    g-l390 likes this.
  2. mdeletrain

    mdeletrain

    Joined:
    Jun 8, 2011
    Posts:
    47
    Answering myself :

    The custom loading screen displayed above Unity had the TYPE_SYSTEM_ALERT flag set. Changing this to the more appropriate TYPE_SYSTEM_OVERLAY flag make the game load again using Unity 4.3+.

    It seems that this should not have been working at the beginning. Unit 4.2.2- may have been to lazy about this.