# SetTreeInstance(int, TreeInstance)

> Sets the tree instance with new parameters at the specified index. However, you cannot change TreeInstance.prototypeIndex and TreeInstance.position. If you change them, the method throws an ArgumentException.

## Definition

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

```csharp
public void SetTreeInstance(int index, TreeInstance instance)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the tree instance.**** (\[TreeInstance]\(/engine/6000.0/script-reference/unityengine/treeinstance)): The new TreeInstance value.
