# GetGeneratedLinksCount(NavMeshDataInstance)

> Obtains the total number of internal navigation links baked into the specified NavMeshDataInstance.

## Definition

* **Type:** Method
* **Namespace:** [Unity.AI.Navigation.LowLevel](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel.md)
* **Assembly:** UnityEngine.AIModule

```csharp
public readonly int GetGeneratedLinksCount(NavMeshDataInstance navMeshInstance)
```

### Parameters

**** (\[NavMeshDataInstance]\(/engine/6000.5/script-reference/unityengine/ai/navmeshdatainstance)): The NavMeshDataInstance to count the baked links for.

### Returns

| Type                                                       | Description                                                                        |
| ---------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The 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](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/getgeneratedlinknodes.md), 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](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/getgeneratedlinknodes.md)

### Examples

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