int A hash code derived from the buffer's internal allocation identifier.
Computes a hash code for identifying this NavQueryBuffer in hash-based collections.
The returned value is suitable for storing the NavQueryBuffer in hash-based collections such as Dictionary or HashSet. Two NavQueryBuffer values that compare equal through NavQueryBuffer.Equals also produce the same hash code.
using System.Collections.Generic; using Unity.Collections; using UnityEngine; using Unity.AI.Navigation.LowLevel; public class NavQueryBufferHashExample : MonoBehaviour { readonly Dictionary<NavQueryBuffer, string> m_Labels = new Dictionary<NavQueryBuffer, string>(); NavWorld m_World; NavQueryBuffer m_Buffer; void OnEnable() { m_World = NavWorld.GetDefaultWorld(); m_Buffer = new NavQueryBuffer(m_World, Allocator.Persistent, 1024); m_Labels[m_Buffer] = "main"; Debug.Log($"Registered buffer with hash {m_Buffer.GetHashCode()}"); } void OnDisable() { // Drop the key before disposing, otherwise the dictionary keeps a stale buffer // whose hash no longer matches the disposed allocation. m_Labels.Remove(m_Buffer); m_Buffer.Dispose(); m_World.Dispose(); } }