Search Unity

Addressables.ReleaseInstance is not deleting object

Discussion in 'Addressables' started by Jribs, Dec 5, 2019.

  1. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    93
    I have discovered that
    Addressables.ReleaseInstance(go)
    is not destroying instances that are not actually addressables.

    We have been told that it is supposed to catch the non addressables and call
    Destroy()
    on them but it doesn't seem to be working.

    Is this a known bug?
     
  2. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    295
    Hey @Jribs I imagine the result of your ReleaseInstance call is false, meaning it wasn't able to release the object you passed in. In the past we would destroy GameObjects for you if they weren't Addressable but I think that led to some awkward states and other various issues (I don't have any details on those issues atm) so we ended up removing that.

    If you have a mix of Addressable instantiated GameObjects and regular instantiated GameObjects and you could be releasing objects from either pool and you're not sure which, I'd suggest something like

    Code (CSharp):
    1. if(!Addressables.ReleaseInstance(myObject))
    2.      Destroy(myObject);
    or something to that effect.
     
  3. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    93
    @DavidUnity3d great thanks that is good to know.

    There are various sources around here that tell us to just replace every Destroy(myObject) with ReleaseInstance(myObject). If that is no longer true, that should probably be updated in the docs or something.
     
  4. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    295
    Yes, very good point. That does need to be updated in the docs. I appreciate you pointing that out.
     
unityunity