Search Unity

Loading a different splash screen if app re-starts mid-usage

Discussion in 'Android' started by drhmiri, Aug 29, 2017.

  1. drhmiri

    drhmiri

    Joined:
    Jun 17, 2014
    Posts:
    76
    In our android unity app, a standard splash screen appears when we start the app (or build to android device) which is done through Unity's Edit -> Project Settings -> Player but we now have a feature that sometimes in the middle of the app, the user presses the home button and re-starts the app, so we would like to code this behavior, so that we can show a different splash screen if the app re-starts mid-usage.

    So, we created a new scene with that extra splash screen and added it to the build with index 4

    What we have already implemented is through:
    Code (CSharp):
    1.  
    2. PlayerPrefs.SetInt("Restarting", 1);
    3. PlayerPrefs.Save();
    4. #if UNITY_ANDROID && !UNITY_EDITOR
    5. AndroidPlugin.Restart();
    6. SceneManager.LoadScene(4);
    7. #else
    8. SceneManager.LoadScene("MainScene");
    9. #endif
    10.  
    which should load the extra splash screen when the app is reloading mid-usage, but it does not...

    What are we missing or doing wrong that the app does not load the new splash screen?

    p.s. The AndroidPlugin.Restart(); clears the memory since we had a lot of crashes to do with android memry management.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    4,663
    How are you running this code? What method is it under? Is it even being called?
     
  3. drhmiri

    drhmiri

    Joined:
    Jun 17, 2014
    Posts:
    76
    Thanks for your reply. This code runs (i.e. the plug-in functions) and it is called in a UnityApplicationController.cs script when the home button is pressed. The plug-in restarts the app and clears the memory (since we had a lot of crashes to do with android memory managements, etc...) but the scene number 4 in build does not get called, because the other splash screen (as a UI canvas image) does not load...