기술 자료

Unity Engine

Unity Engine

Dispose()

Destroys the NavQueryBuffer and deallocates all memory used by it.
읽는 시간 1분최근 업데이트: 한 달 전

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. Each NavQueryBuffer you create must be paired with exactly one call to NavQueryBuffer.Dispose.

Examples

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