# CollectSources

> Collects renderers or physics colliders, and terrains within a volume. This function might not collect some MeshColliders that are a distance greater than 1E7 from the origin.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.AI](/engine/6000.0/script-reference/unityengine/ai.md)
* **Assembly:** UnityEngine.AIModule

## CollectSources(Bounds, int, NavMeshCollectGeometry, int, bool, List\<NavMeshBuildMarkup>, bool, List\<NavMeshBuildSource>)

Collects renderers or physics colliders, and terrains within a volume. This function might not collect some MeshColliders that are a distance greater than 1E7 from the origin.

```csharp
public static void CollectSources(Bounds includedWorldBounds, int includedLayerMask, NavMeshCollectGeometry geometry, int defaultArea, bool generateLinksByDefault, List<NavMeshBuildMarkup> markups, bool includeOnlyMarkedObjects, List<NavMeshBuildSource> results)
```

### Parameters

**** (\[Bounds]\(/engine/6000.0/script-reference/unityengine/bounds)): The queried objects must overlap these bounds to be included in the results.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Specifies which layers are included in the query.**** (\[NavMeshCollectGeometry]\(/engine/6000.0/script-reference/unityengine/ai/navmeshcollectgeometry)): Which type of geometry to collect - e.g. physics colliders.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Area type to assign to results, unless modified by NavMeshMarkup.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, all the source will be considered for generating links. Otherwise, only the marked sources will be considered.**** (\[List\<NavMeshBuildMarkup>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): List of markups which allows finer control over how objects are collected.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Specifies if only objects with markups are collected.**** (\[List\<NavMeshBuildSource>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): List where results are stored, the list is cleared at the beginning of the call.

### Remarks

For convenience, you can create a list of build sources directly from the current geometry.

The collection can be controlled in terms of layers, type of geometry and by collecting either by hierarchy or volume.

## CollectSources(Bounds, int, NavMeshCollectGeometry, int, List\<NavMeshBuildMarkup>, List\<NavMeshBuildSource>)

Collects renderers or physics colliders, and terrains within a volume. This function might not collect some MeshColliders that are at a distance greater than 1E7 from the origin.

```csharp
public static void CollectSources(Bounds includedWorldBounds, int includedLayerMask, NavMeshCollectGeometry geometry, int defaultArea, List<NavMeshBuildMarkup> markups, List<NavMeshBuildSource> results)
```

### Parameters

**** (\[Bounds]\(/engine/6000.0/script-reference/unityengine/bounds)): The queried objects must overlap these bounds to be included in the results.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Specifies which layers are included in the query.**** (\[NavMeshCollectGeometry]\(/engine/6000.0/script-reference/unityengine/ai/navmeshcollectgeometry)): Which type of geometry to collect - e.g. physics colliders.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Area type to assign to results, unless modified by NavMeshMarkup.**** (\[List\<NavMeshBuildMarkup>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): List of markups which allows finer control over how objects are collected.**** (\[List\<NavMeshBuildSource>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): List where results are stored, the list is cleared at the beginning of the call.

## CollectSources(Transform, int, NavMeshCollectGeometry, int, bool, List\<NavMeshBuildMarkup>, bool, List\<NavMeshBuildSource>)

Collects renderers or physics colliders, and terrains within a transform hierarchy.

```csharp
public static void CollectSources(Transform root, int includedLayerMask, NavMeshCollectGeometry geometry, int defaultArea, bool generateLinksByDefault, List<NavMeshBuildMarkup> markups, bool includeOnlyMarkedObjects, List<NavMeshBuildSource> results)
```

### Parameters

**** (\[Transform]\(/engine/6000.0/script-reference/unityengine/transform)): If not null, consider only root and its children in the query; if null, includes everything loaded.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Specifies which layers are included in the query.**** (\[NavMeshCollectGeometry]\(/engine/6000.0/script-reference/unityengine/ai/navmeshcollectgeometry)): Which type of geometry to collect - e.g. physics colliders.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Area type to assign to results, unless modified by NavMeshMarkup.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, all the source will be considered for generating links. Otherwise, only the marked sources will be considered.**** (\[List\<NavMeshBuildMarkup>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): List of markups which allows finer control over how objects are collected.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Specifies if only objects with markups are collected.**** (\[List\<NavMeshBuildSource>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): List where results are stored, the list is cleared at the beginning of the call.

## CollectSources(Transform, int, NavMeshCollectGeometry, int, List\<NavMeshBuildMarkup>, List\<NavMeshBuildSource>)

Collects renderers or physics colliders, and terrains within a transform hierarchy.

```csharp
public static void CollectSources(Transform root, int includedLayerMask, NavMeshCollectGeometry geometry, int defaultArea, List<NavMeshBuildMarkup> markups, List<NavMeshBuildSource> results)
```

### Parameters

**** (\[Transform]\(/engine/6000.0/script-reference/unityengine/transform)): If not null, consider only root and its children in the query; if null, includes everything loaded.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Specifies which layers are included in the query.**** (\[NavMeshCollectGeometry]\(/engine/6000.0/script-reference/unityengine/ai/navmeshcollectgeometry)): Which type of geometry to collect - e.g. physics colliders.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Area type to assign to results, unless modified by NavMeshMarkup.**** (\[List\<NavMeshBuildMarkup>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): List of markups which allows finer control over how objects are collected.**** (\[List\<NavMeshBuildSource>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): List where results are stored, the list is cleared at the beginning of the call.
