GetGeneratedLinkNodes(NavMeshDataInstance, NativeSlice<NavNode>, int, int)
Retrieves the NavNode identifiers for internal navigation links baked into the specified NavMeshDataInstance.
Read time 2 minutesLast updated 22 days ago
Definition
- Type: Method
- Namespace: Unity.AI.Navigation.LowLevel
- Assembly: UnityEngine.AIModule
public readonly int GetGeneratedLinkNodes(NavMeshDataInstance navMeshInstance, NativeSlice<NavNode> linkNodes, int start = 0, int length = 2147483647)
Parameters
The NavMeshDataInstance that contains the baked links.
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.
The zero-based index of the first baked link to retrieve. The default value is 0.
The maximum number of baked links to retrieve. The default value is , which retrieves all the remaining links from .
int.MaxValuestartReturns
Type | Description |
|---|---|
| int | The number of NavNode identifiers written into |
Remarks
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 buffer.
linkNodesThe and parameters let you retrieve a subset of the full list. Retrieving a subset is useful when you process large batches.
startlengthExamples
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(); }}