Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Handle of Addressables.InitializeAsync() becomes invalid when it's done

Discussion in 'Addressables' started by kmy_, Apr 2, 2020.

  1. kmy_

    kmy_

    Joined:
    Apr 19, 2018
    Posts:
    4
    Unity 2018.4.13f1 / Addressables 1.7.5

    Hi, I tried to check whether the initialization succeeded and this occurs always:
    Code (CSharp):
    1. var handle = Addressables.InitializeAsync();
    2. await handle.Task;
    3. Debug.Log(handle.Status); // <--- System.Exception: Attempting to use an invalid operation handle
    Does anyone know how can I get rid of this exception, thanks.
     
    Last edited: Apr 2, 2020
    chanon81 likes this.
  2. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    568
    No idea why that would break after awaiting the task, but try using the onComplete method to see if that works.
     
    kmy_ likes this.
  3. kmy_

    kmy_

    Joined:
    Apr 19, 2018
    Posts:
    4
    Thanks, it worked!

    Now I have encountered another problem by the way:
    Code (CSharp):
    1. Addressables.InitializeAsync().Completed += (handle) => {
    2. Debug.Log(handle.Status); // <--- always "Succeeded", even when it failed
    3. Debug.Log(handle.OperationException); // <--- always "Null", even when it failed
    4.  };

    I'm also getting worried about what can I do when initialization failed.
    Calling InitializaAsync() again seems to do nothing.
     
  4. afeiloo

    afeiloo

    Joined:
    Feb 7, 2020
    Posts:
    3
    because Addressables ignore the exception, I can't understand why
    func -> InitializationOperation.CreateInitializationOperation()
     
  5. adani_zynga

    adani_zynga

    Joined:
    Oct 6, 2022
    Posts:
    5
    IdeenMolavi likes this.