Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Dispose()

Releases this NavWorld handle and prevents any further operations on it.
Read time 1 minuteLast updated 22 days ago

Definition

public void Dispose()

Remarks

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.

Examples

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(); }}