Search Unity

Release instance on non-addressable game objects

Discussion in 'Addressables' started by iamarugin, May 7, 2019.

  1. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    I see the deprecation warning when trying to use Addressables.ReleaseInstance(gameObject); on the gameObject, that previously was not created with the Addressables. So, what will be the right way to do something like this or we always have to track by ourselfs which objects come from Addressables and which not?
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    We hadn't locked that in when we wrote the warning, so we didn't explain it there, but the plan is to return a success bool. So your code would be something like:

    Code (CSharp):
    1.         if(!Addressables.ReleaseInstance(myGameObject))
    2.             GameObject.Destroy(myGameObject);
    Once this comes out, we'll update the docs and note it in the changelog.
     
    HOPEGIVER, wlwl2 and senfield like this.
  3. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    of note, once this returns the bool, it will no longer print a warning if it gets something it doesn't recognize.
     
  4. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Thanks for clarification.