---
title: "replace(withImage:options:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/textureresource/replace(withimage:options:)"
---

# replace(withImage:options:)

Dynamically replaces the texture with a Core Graphics image.

## Declaration

```swift
@MainActor @preconcurrency func replace(withImage cgImage: CGImage, options: TextureResource.CreateOptions) throws
```

## Parameters

- `cgImage`: The source image.
- `options`: Options that specify the type of texture to create.

## Discussion

Discussion This method blocks until the resource updates. Don’t use this method for updates at frame-rate frequency. For frequent texture changes, see replace(withDrawables:). If you have an attached TextureResource.DrawableQueue on this resource, this function detaches it. To  ensure consistent usage of this texture resource, pass the same semantic in options that you use to create the resource. note: The contents of a modified texture resource don’t sync between network clients.

## See Also

### Modifying the texture

- [replace(withDrawables:)](realitykit/textureresource/replace(withdrawables:).md)
- [replace(using:options:)](realitykit/textureresource/replace(using:options:).md)
- [replace(with:)](realitykit/textureresource/replace(with:).md)
