Destroys the NavQueryBuffer and deallocates all memory used by it.
Call this method when the buffer is no longer needed. After you dispose it, the NavQueryBuffer can't be reused, and any subsequent NavWorld pathfinding call that receives it throws an exception when executed in the Editor. Each NavQueryBuffer you create must be paired with exactly one call to NavQueryBuffer.Dispose.
using Unity.Collections; using UnityEngine; using Unity.AI.Navigation.LowLevel; public class NavQueryBufferDisposeExample : MonoBehaviour { NavWorld m_World; NavQueryBuffer m_Buffer; void OnEnable() { m_World = NavWorld.GetDefaultWorld(); m_Buffer = new NavQueryBuffer(m_World, Allocator.Persistent, 1024); } void OnDisable() { // Release the native memory allocated by the constructor, then the world handle. m_Buffer.Dispose(); m_World.Dispose(); } }