# GetGeneratedLinkNodes(NavMeshDataInstance, NativeSlice<NavNode>, int, int)

> Retrieves the NavNode identifiers for 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 GetGeneratedLinkNodes(NavMeshDataInstance navMeshInstance, NativeSlice<NavNode> linkNodes, int start = 0, int length = 2147483647)
```

### Parameters

**** (\[NavMeshDataInstance]\(/engine/6000.5/script-reference/unityengine/ai/navmeshdatainstance)): The NavMeshDataInstance that contains the baked links.**** (\[NativeSlice\<NavNode>]\(/engine/6000.5/script-reference/unity/collections/nativeslice1)): 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](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/getgeneratedlinkscount.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The zero-based index of the first baked link to retrieve. The default value is 0.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The maximum number of baked links to retrieve. The default value is `int.MaxValue`, which retrieves all the remaining links from `start`.

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of NavNode identifiers written into `linkNodes`. |

### Remarks

Certain NavMesh baking workflows produce internal navigation links stored directly in the [NavMeshData](/engine/6000.5/script-reference/unityengine/ai/navmeshdata.md) that act similarly to NavMesh Links but aren't individually accessible as separate runtime objects. Use [NavWorld.GetGeneratedLinksCount](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/getgeneratedlinkscount.md) to determine how many such links a [NavMeshDataInstance](/engine/6000.5/script-reference/unityengine/ai/navmeshdatainstance.md) 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](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/getgeneratedlinkscount.md), [NavWorld.GetLinkNode](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/getlinknode.md), [NavWorld.IsValid](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/isvalid.md)

### Examples

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