Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

How to release a failed handle?

Discussion in 'Addressables' started by SviperSniper, Mar 25, 2020.

  1. SviperSniper

    SviperSniper

    Joined:
    Mar 1, 2017
    Posts:
    16
    Hey,
    how do I release the handle of a failed operation?

    When the download of a bundle fails, the operation completes but the operation and all its dependencies are still shown in the Event Viewer forever.

    Does this mean, that the resources are not unloaded if one of the operations fails?

    Calling ReleaseInstance (after InstantiateAsync) throws a NullPointer because the Result of the handle is null, calling Release (also after InstantiateAsync) crashes the whole editor...

    Releasing handles is a pain right now as it also breaks the whole system when releasing an AsyncOperation handle more than one time...
     
  2. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    161
    I do this, though I haven't actually checked if it cleans up the resources or not. Can you let me know if this works for you?

    Code (CSharp):
    1. if (handle.IsValid())
    2. {
    3.     Addressables.Release(handle);
    4. }
     
  3. SviperSniper

    SviperSniper

    Joined:
    Mar 1, 2017
    Posts:
    16
    I am using Addressables.InstantiateAsync, so the correct function should be Addressables.ReleaseInstance.
    But, as written, this causes a NullPointer because it tries to release a null instance.
    With Addressables.Release it completly crashes the editor.
     
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    210
    Hey there @SviperSniper - which version of Addressable, and the Editor, are you using?
     
  5. SviperSniper

    SviperSniper

    Joined:
    Mar 1, 2017
    Posts:
    16
    Hey,
    We are using:
    Unity: 2019.2.21f1
    Addressables: 1.6.2
     
    Last edited: Mar 27, 2020
unityunity