| Parameter | Description |
|---|---|
| navMeshInstance | The NavMeshDataInstance to count the baked links for. |
int The total number of navigation links baked into the specified NavMeshDataInstance.
Obtains the total number of internal navigation links baked into the specified NavMeshDataInstance.
Use the returned count to size the buffer that you pass to NavWorld.GetGeneratedLinkNodes, so that a single call retrieves all the baked links. The count covers only the links baked into the NavMeshData itself, not the links added separately to the navigation system at runtime.
Additional resources: NavWorld.GetGeneratedLinkNodes
using Unity.Collections; using UnityEngine; using UnityEngine.AI; using Unity.AI.Navigation.LowLevel; public class GeneratedLinksCountExample : MonoBehaviour { public NavMeshData data; void Start() { NavMeshDataInstance instance = NavMesh.AddNavMeshData(data); using NavWorld world = NavWorld.GetDefaultWorld(); int total = world.GetGeneratedLinksCount(instance); Debug.Log($"NavMeshData contains {total} baked navigation links."); NativeArray<NavNode> links = new NativeArray<NavNode>(total, Allocator.Temp); world.GetGeneratedLinkNodes(instance, links); links.Dispose(); instance.Remove(); } }