<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/TextureResource/replace(withImage:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation15TextureResourceC7replace9withImage7optionsySo10CGImageRefa_AC13CreateOptionsVtKF"
  },
  "title" : "replace(withImage:options:)"
}
-->

# replace(withImage:options:)

Dynamically replaces the texture with a Core Graphics image.

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

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:)`](/documentation/RealityKit/TextureResource/replace(withDrawables:)).
If you have an attached [`TextureResource.DrawableQueue`](/documentation/RealityKit/TextureResource/DrawableQueue-swift.class) 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.

---

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)