| Parameter | Description |
|---|---|
| navMeshInstance | The NavMeshDataInstance that contains the baked links. |
| linkNodes | The buffer to fill with the NavNode identifiers of the baked links. It can have zero capacity when you need only the count returned by NavWorld.GetGeneratedLinksCount. |
| start | The zero-based index of the first baked link to retrieve. The default value is 0. |
| length | The maximum number of baked links to retrieve. The default value is int.MaxValue, which retrieves all the remaining links from start. |
int
The number of NavNode identifiers written into linkNodes.
Retrieves the NavNode identifiers for internal navigation links baked into the specified NavMeshDataInstance.
Certain NavMesh baking workflows produce internal navigation links stored directly in the NavMeshData that act similarly to NavMesh Links but aren't individually accessible as separate runtime objects. Use NavWorld.GetGeneratedLinksCount to determine how many such links a NavMeshDataInstance contains before sizing the linkNodes buffer.
The start and length parameters let you retrieve a subset of the full list. Retrieving a subset is useful when you process large batches.
Additional resources: NavWorld.GetGeneratedLinksCount, NavWorld.GetLinkNode, NavWorld.IsValid
using Unity.Collections; using UnityEngine; using UnityEngine.AI; using Unity.AI.Navigation.LowLevel; public class GeneratedLinkNodesExample : MonoBehaviour { public NavMeshData data; NavMeshDataInstance m_Instance; void OnEnable() { // Query the links right after adding the data, so that re-enabling this component // re-reads the links of the instance it just created. m_Instance = NavMesh.AddNavMeshData(data); using NavWorld world = NavWorld.GetDefaultWorld(); int total = world.GetGeneratedLinksCount(m_Instance); NativeArray<NavNode> links = new NativeArray<NavNode>(total, Allocator.Temp); int written = world.GetGeneratedLinkNodes(m_Instance, links); for (int i = 0; i < written; i++) Debug.Log($"Generated link {i}: agent type {world.GetAgentTypeIdForNode(links[i])}"); links.Dispose(); } void OnDisable() { m_Instance.Remove(); } }