# SetTreeInstances(TreeInstance[], bool)

> Sets the Tree Instance array, and optionally snaps Trees onto the surface of the Terrain heightmap.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.TerrainModule

```csharp
public void SetTreeInstances(TreeInstance[] instances, bool snapToHeightmap)
```

### Parameters

**** (\[TreeInstance\[]]\(/engine/6000.6/script-reference/unityengine/treeinstance)): The array of [TreeInstance](/engine/6000.6/script-reference/unityengine/treeinstance.md) objects.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Specifies whether to snap Trees to the Terrain heightmap.

### Remarks

Additional Resources: [TerrainData.treeInstances](/engine/6000.6/script-reference/unityengine/terraindata/treeinstances.md).
