Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetGeneratedLinksCount(NavMeshDataInstance)

Obtains the total number of internal navigation links baked into the specified NavMeshDataInstance.
Read time 1 minuteLast updated 19 days ago

Definition

public readonly int GetGeneratedLinksCount(NavMeshDataInstance navMeshInstance)

Parameters

navMeshInstance

The NavMeshDataInstance to count the baked links for.

Returns

Type

Description

intThe total number of navigation links baked into the specified NavMeshDataInstance.

Remarks

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

Examples

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