---
title: "setMeshInstance(_:index:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowlevelmeshinstancearray/setmeshinstance(_:index:)"
---

# setMeshInstance(_:index:)

Assigns a mesh instance to the slot at the given index, or clears the slot if the instance is nil.

## Declaration

```swift
final func setMeshInstance(_ newElement: LowLevelMeshInstanceArray.Element, index: Int) throws(LowLevelRenderContextError)
```

## Parameters

- `newElement`: The mesh instance to assign, or nil to clear the slot.
- `index`: The slot index to assign to.

## Discussion

Discussion You are responsible for ensuring index is within 0..<count. note: LowLevelRenderContextError if the render target descriptors of the array are not a subset of the render target descriptors of the mesh instance’s pipeline state.

## See Also

### Setting mesh instances

- [count](realitykit/lowlevelmeshinstancearray/count.md)
