<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/TextureResource/init(named:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation15TextureResourceC0A3KitE5named2inACSS_So8NSBundleCSgtYaKcfc"
  },
  "title" : "init(named:in:)"
}
-->

# init(named:in:)

Asynchronously loads a texture resource from a bundle.

```
@MainActor @preconcurrency convenience init(named name: String, in bundle: Bundle? = nil) async throws
```

## Parameters

`name`

The name of the resource. The filename extension is optional.

`bundle`

The bundle to search for the resource. Use `nil` to indicate
the app’s bundle.

## Discussion

RealityKit automatically creates a resource name for the texture
resource based on the values of `name` and `bundle`. RealityKit uses the
resource name to identify resources, and to match texture resources
between networked peers. Specify a unique name for each texture resource
you load or generate.

Load textures concurrently with other content for optimal load times without
causing your app to hitch.

```swift
struct SomeRealityView: View {
    var body: some View {
        RealityView { content in
            // Begin loading the texture.
            async let textureA = try? TextureResource(named:"textureA.jpg")
            // Load the scene.
            guard let rootEntity = try? await Entity(named: "SceneA", in: realityKitContentBundle) else {
                return
            }
            // Wait for the texture to finish loading.
            guard let textureA = await textureA else {
                return
            }

            // Create and assign a material that uses the texture to a model entity.
            if let entityA = rootEntity.findEntity(named: "ModelA") as? ModelEntity {
                var material = PhysicallyBasedMaterial()
                material.baseColor = PhysicallyBasedMaterial.BaseColor(tint: .white,
                                                                       texture: .init(textureA))
                entityA.model?.materials[0] = material
            }

            content.add(rootEntity)
        }
    }
}
```

---

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)