Will OnDestroy call IDisposable? No ?

Just wondering if Unity3d calls IDisposable.Dispose() behind the scenes. I have done some basic web searches without success.

I created a test project. It has two scripts. The first script includes a context method to destroy itself. The second script includes a context method which calls GC.Collect.

public class Test : MonoBehaviour, IDisposable
{        
    [ContextMenu("DestroyMe")]
    public void DestroyMe()
    {
        Destroy(gameObject);
    }

    void OnDestroy()
    {
        Debug.Log("OnDestroy");
    }

    public void Dispose()
    {
        Debug.Log("Dispose");
    }
}

public class TestManager : MonoBehaviour
{
    [ContextMenu("GC.Collect")]
    public void GCCollect()
    {
        GC.Collect();
    }
}

The end result was that Dispose never appeared in my debug.log. It appears that unity does not check for IDisposable. This is unfortunate.

I am seeing the same behavior. Instead of having my MonoBehavior implement IDisposable, I separated my native resources into a separate IDisposable class and explicitly called Dispose() from the MonoBehavior’s OnDestroy.