Documentation

Unity Engine

Download Unity

Unity Engine

Dispose()

Destroys the NavQueryBuffer and frees the memory it uses.
Read time 1 minuteLast updated 8 hours ago

Definition

public void Dispose()

Remarks

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. Call
Dispose
exactly once for each NavQueryBuffer you create.

Examples

using Unity.Collections;using UnityEngine;using Unity.AI.Navigation.LowLevel;// Attach this script to a GameObject. When the GameObject is disabled, the script disposes the// NavQueryBuffer and the NavWorld handle to free their native memory.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(); }}