Search Unity

Bug Addressables.LoadAssetsAsync don't work as expected

Discussion in 'Addressables' started by shlakva, Dec 7, 2022.

  1. shlakva

    shlakva

    Joined:
    Oct 15, 2017
    Posts:
    15
    Code (CSharp):
    1. public static AsyncOperationHandle<IList<TObject>> LoadAssetsAsync<TObject>(IEnumerable keys, Action<TObject> callback, MergeMode mode, bool releaseDependenciesOnFailure)
    Description says:
    "If any assets cannot be loaded, the entire operation fails. The operation releases any assets and dependencies it had already loaded.
    The `Status` of the operation handle is set to "AsyncOperationStatus.Failed" and the `Result` is set to null."

    Here is the real example(keys are labels):
    Code (CSharp):
    1. private static List<string> list = new() { "validKey", "nonValidKey" };
    2.  
    3. Addressables.LoadAssetsAsync<GameObject>(list, go =>
    4. {
    5.      // ...
    6. }, Addressables.MergeMode.Union, true);
    7.  
    Operation successfull, no errors thrown, no Status change to "Failed". Result is populated with data only from "validKey".

    On the other hand this example:
    Code (CSharp):
    1. private static List<string> list = new() { "nonValidKey" };
    2.  
    3. Addressables.LoadAssetsAsync<GameObject>(list, go =>
    4. {
    5.      // ...
    6. }, Addressables.MergeMode.Union, true);
    7.  
    will produce InvalidKeyException and change Status to "Failed".

    This is obviously a bug. Please confirm, or maybe I missed something? Thanks!
     
    Last edited: Dec 7, 2022
  2. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hi @shlakva could you elaborate more on the expected behavior? Are you expecting the first example to fail? Assuming that "nonValidKey" is not a valid label, the two examples appear to be correct.