Search Unity

PackedMode and weird behaviour

Discussion in 'Addressables' started by aurelien-morel-ubiant, Dec 13, 2018.

  1. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    Hello Addressables guys !
    I'm trying to make some assets working with Addressables logic. I have something extra smooth in Fast & Virtual Mode. I didn't find issue, all the bundle seems to be build and read from their good location.

    Here my Scripting defines symbols to debug and manage the Initialization on my own :
    - USE_ADDRESSABLE_LOG
    - ADDRESSABLES_DISABLE_AUTO_INITIALIZATION

    Here is what I'm doing. Which is barely what I could read on some post or in your documentation.

    Code (CSharp):
    1. public void Start()
    2. {
    3.  
    4. IAsyncOperation<IResourceLocator> iasyncLoc = Addressables.Initialize();
    5. iasyncLoc.Completed += OnResourceLocatorComplete;
    6.  
    7. }
    8.  
    9. private void OnResourceLocatorComplete(IAsyncOperation<IResourceLocator> resourceLocator)
    10. {
    11.         Debug.Log($"resourceLocator.Current : {resourceLocator.Current}");
    12.         Debug.Log($"resourceLocator.Context : {resourceLocator.Context}");
    13.         Debug.Log($"resourceLocator.IsDone : {resourceLocator.IsDone}");
    14.         Debug.Log($"resourceLocator.IsValid : {resourceLocator.IsValid}");
    15.         Debug.Log($"resourceLocator.Key : {resourceLocator.Key}");
    16.         Debug.Log($"resourceLocator.OperationException : {resourceLocator.OperationException}");
    17.         Debug.Log($"resourceLocator.PercentComplete : {resourceLocator.PercentComplete}");
    18.         Debug.Log($"resourceLocator.Result : {resourceLocator.Result}");
    19.         Debug.Log($"resourceLocator.Status : {resourceLocator.Status}");
    20.         Debug.Log($"resourceLocator.ToString : {resourceLocator.ToString()}");
    21.  
    22.         if (resourceLocator.Status == AsyncOperationStatus.Succeeded)
    23.         {
    24.             Debug.Log("LOAD CATALOG OK");
    25.             IAsyncOperation<Texture2D> iasyncTexture = Addressables.LoadAsset<Texture2D>(m_ImageRef);
    26.             iasyncTexture.Completed += OnLoadAssetComplete;
    27.         }
    28.         else
    29.         {
    30.             Debug.Log("LOAD CATALOG NOT OK");
    31.         }
    32. }
    33.  
    34. private void OnLoadAssetComplete(IAsyncOperation<Texture2D> loadOp)
    35.     {
    36.         Debug.Log($"loadOp.Current : {loadOp.Current}");
    37.         Debug.Log($"loadOp.Context : {loadOp.Context}");
    38.         Debug.Log($"loadOp.IsDone : {loadOp.IsDone}");
    39.         Debug.Log($"loadOp.IsValid : {loadOp.IsValid}");
    40.         Debug.Log($"loadOp.Key : {loadOp.Key}");
    41.         Debug.Log($"loadOp.OperationException : {loadOp.OperationException}");
    42.         Debug.Log($"loadOp.PercentComplete : {loadOp.PercentComplete}");
    43.         Debug.Log($"loadOp.Result : {loadOp.Result}");
    44.         Debug.Log($"loadOp.Status : {loadOp.Status}");
    45.         Debug.Log($"loadOp.ToString : {loadOp.ToString()}");
    46.  
    47.         if (loadOp.Status == AsyncOperationStatus.Succeeded && loadOp.Result != null)
    48.         {
    49.             m_Image.enabled = true;
    50.             m_Image.texture = loadOp.Result;
    51.             Debug.Log("LOAD ASSET  OK");
    52.         }
    53.         else
    54.         {
    55.             Debug.Log("LOAD ASSET REQUEST NOT VALID");
    56.             Debug.Log("STATUS : " + loadOp.Status + " // Resulting asset : " + loadOp.Result);
    57.         }
    58.     }

    But in PackedMode it's not smooth as the others could be.
    When I check frame by frame what happen. Here what I obtain :

    Frame 1 :
    upload_2018-12-13_15-24-50.png

    Frame 2 :
    upload_2018-12-13_15-25-10.png

    Frame 3 :
    upload_2018-12-13_15-25-39.png

    Frame 4 :
    upload_2018-12-13_15-25-59.png

    And that's all. My texture is never load and the most weird things according to me is the Completed event which is triggered even if the loadOp.isDone remains false. I tried with some coroutine and
    Code (CSharp):
    1. while(!loadOp.isDone)
    2. yield return null;
    and the value seems to remain false forever (Maybe I'm wrong but it surprises me, Completed event is not plugged on this variable ?)