public void Dispose() { bool allowReadOrWriteAccess = AtomicSafetyHandle.GetAllowReadOrWriteAccess(this.m_Safety); DisposeSentinel.Dispose(ref this.m_Safety, ref this.m_DisposeSentinel); bool flag = allowReadOrWriteAccess; if (flag) { NavMeshQuery.RemoveQuerySafety(this.m_NavMeshQuery, this.m_Safety); } NavMeshQuery.Destroy(this.m_NavMeshQuery); this.m_NavMeshQuery = IntPtr.Zero; }
public void Dispose() { // When the NavMesh destroys itself it will disable read or write access. // Since it has been deallocated, we shouldn't deregister the query from it... // We need to extract removeQuery before disposing the handle, // because the atomic safety handle stores that state. var removeQuery = AtomicSafetyHandle.GetAllowReadOrWriteAccess(m_Safety); DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel); if (removeQuery) { RemoveQuerySafety(m_NavMeshQuery, m_Safety); } Destroy(m_NavMeshQuery); m_NavMeshQuery = IntPtr.Zero; }