ドキュメント

Unity Engine

Unity Engine

Dispose()

Destroys the NavQueryBuffer and deallocates all memory used by it.
読み終わるまでの所要時間 1 分最終更新 2ヶ月前

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