Releases this NavWorld handle and prevents any further operations on it.
Call this method when you no longer need to use the NavWorld. After calling it, the NavWorld becomes invalid and all of its methods return invalid results or throw exceptions when executed in the Editor. Other handles to the same navigation data aren't affected. To destroy the underlying navigation system use NavMesh.RemoveAllNavMeshData.
using Unity.Collections; using UnityEngine; using Unity.AI.Navigation.LowLevel; public class NavWorldLifecycleExample : 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 per-query buffer first, then release the NavWorld handle. m_Buffer.Dispose(); m_World.Dispose(); } }