int The hash code derived from the node identifier, suitable for use in hash-based collections.
Obtains the hash code of this NavNode for use in collections.
The returned value is derived from the internal identifier of the NavNode and is suitable for storing nodes in hash-based collections such as Dictionary or HashSet. Two NavNode values that compare equal through NavNode.Equals also produce the same hash code.
using System.Collections.Generic; using UnityEngine; using Unity.AI.Navigation.LowLevel; public class NavNodeHashExample : MonoBehaviour { readonly HashSet<NavNode> m_VisitedNodes = new HashSet<NavNode>(); void Update() { using NavWorld world = NavWorld.GetDefaultWorld(); NavLocation location = world.MapLocation(transform.position, Vector3.one, 0); if (world.IsValid(location) && m_VisitedNodes.Add(location.node)) Debug.Log($"Recorded new node, hash {location.node.GetHashCode()}"); } }