Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Please add method like ReleaseInstance that takes object instead of GameObject

Discussion in 'Addressables' started by DragonTein, Jul 1, 2021.

  1. DragonTein

    DragonTein

    Joined:
    Jul 1, 2018
    Posts:
    15
    Addressables.Release gives you LogError when you try to release object that adressables are not aware of.
    Addressables.ReleaseInstance returns useful bool.
    ive looked at disassembled code and they are identical. Please implement methond with (public bool Release<TObject>(TObject obj)) signature.


    Code (CSharp):
    1. public bool ReleaseInstance(GameObject instance)
    2.         {
    3.             if (instance == null)
    4.             {
    5.                 LogWarning("Addressables.ReleaseInstance() - trying to release null object.");
    6.                 return false;
    7.             }
    8.  
    9.             AsyncOperationHandle handle;
    10.             if (m_resultToHandle.TryGetValue(instance, out handle))
    11.                 Release(handle);
    12.             else
    13.                 return false;
    14.  
    15.             return true;
    16.         }
    Code (CSharp):
    1.   public void Release<TObject>(TObject obj)
    2.         {
    3.             if (obj == null)
    4.             {
    5.                 LogWarning("Addressables.Release() - trying to release null object.");
    6.                 return;
    7.             }
    8.  
    9.             AsyncOperationHandle handle;
    10.             if (m_resultToHandle.TryGetValue(obj, out handle))
    11.                 Release(handle);
    12.             else
    13.             {
    14.                 LogError("Addressables.Release was called on an object that Addressables was not previously aware of.  Thus nothing is being released");
    15.             }
    16.         }
     
    kevinlin3 likes this.