<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/LowLevelMeshInstanceArray/setMeshInstance(_:index:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:19RealityCoreRenderer25LowLevelMeshInstanceArrayC03setfG0_5indexyAA0defG0CSg_SitAA0dE18RenderContextErrorVYKF"
  },
  "title" : "setMeshInstance(_:index:)"
}
-->

# setMeshInstance(_:index:)

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

```
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

The `index` must be at least `0` and less than `count`.

> Throws: ``doc://com.apple.RealityKit/documentation/RealityKit/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)