Search Unity

AsyncOperation of UnloadUnusedAssets takes too long sometimes.

Discussion in 'Android' started by GarlicDipping, Mar 22, 2018.

  1. GarlicDipping

    GarlicDipping

    Joined:
    Sep 7, 2013
    Posts:
    33
    Hi, I'm using Coroutine when waiting for Resources.UnloadUnusedAssets() operation to finish in loading screen.

    It works well in most times, but sometimes this operation takes too long to get async.isDone true.

    Here's my code :

    Code (CSharp):
    1.  
    2.     public IEnumerator DestroyAndUnloadAndSwapToAsync(string name, object value)
    3.     {
    4.         Debug.Log("unload Start : " + Time.realtimeSinceStartup);
    5.         AsyncOperation async = Resources.UnloadUnusedAssets();
    6.         while (!async.isDone)
    7.         {
    8.             yield return null;
    9.             Debug.Log(async.progress +" / Priority : " + async.priority + " / Time : " + Time.realtimeSinceStartup);
    10.         }
    11.         Debug.Log("unload Done : " + Time.realtimeSinceStartup);
    12.     }
    Yeah, It's very simple code. But sometimes async.progress stays in 0 about 1 min~ forever in android devices.

    I don't have a clue what's wrong with this. Any suggestions?

    (Using Unity 2017.1.1f1)