Search Unity

[0.6.7] Unexpected behavior using label with LoadAssets

Discussion in 'Addressables' started by Deleted User, Mar 29, 2019.

  1. Deleted User

    Deleted User

    Guest

    Unity 2018.3.8f1
    Addressables 0.6.7


    After playing around with labels, I still struggle with something that doesn't look like it was the intended behavior. I attached a pretty simple project to display this use case, but here's the explication of the case demonstrated in the sample.

    For simplicity I'll be using 2 specific types here, but the behavior is the same with any asset type.

    - Have some Texture and AnimationClip as addressable and marked with a label named "Label".

    Then, at some point in your code you want to load the textures for this label, but not the animations yet.

    Calling Addressables.LoadAssets<Texture2D>("Label", ...); will load ALL assets marked with this label into memory, not just textures. The result of the IAsyncOperation<IList<Texture2D>> returned will contain an item for each asset, but the ones that are not Texture2D will be null.

    2 major issues occur at this point:

    1. Calling Addressables.Release(asset); for each valid texture you loaded will release them properly, but animations will remain in memory forever. There doesn't seem to be any way of releasing them since you never got valid references in the first place.

    2. Calling Addressables.LoadAssets<AnimationClip>("Label", ...); after having loaded the textures first will fail, throwing an "InvalidCastException: Specified cast is not valid.", but will still increase the ref count of all assets.

    This is pretty much forcing me to use a different label per asset type for it to work "properly".

    Known issue?
    Expected behavior?
    Not the intended usage of labels?

    I wish the steps are clear enough. Looking at the Addressables Profiler while testing this will show you very clearly what's happening.

    Cheers.
     

    Attached Files:

  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    That's definitely not what it is supposed to do. I've opened a bug in our system to investigate.
     
  3. Neadrim

    Neadrim

    Joined:
    Sep 26, 2017
    Posts:
    6