Contents

load(named:in:)

Synchronously loads an environment resource from a bundle.

Declaration

@MainActor @preconcurrency static func load(named name: String, in bundle: Bundle? = nil) throws -> EnvironmentResource

Parameters

  • name:

    The image name without the file extension.

  • bundle:

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

Return Value

The environment resource that loads from the specified bundle.

Discussion

Loading an EnvironmentResource with this method blocks the main actor because it’s synchronous, so only call it from a command-line application. The method can stall a regular app, which makes it visibly hitch, and the system terminates an app if its UI becomes unresponsive.

If your image file is at the path Foo.skybox/Bar.exr in your Xcode project, use Bar for the name parameter.

To add an environment resource to your Xcode project, see EnvironmentResource.

See Also

Loading the resource