newTextures(names:scaleFactor:displayGamut:bundle:options:completionHandler:)
Asynchronously loads image data and creates Metal textures from the specified list of named texture assets in an asset catalog.
Declaration
func newTextures(names: [String], scaleFactor: CGFloat, displayGamut: NSDisplayGamut, bundle: Bundle?, options: [MTKTextureLoader.Option : Any]? = nil, completionHandler: @escaping @Sendable ([any MTLTexture], (any Error)?) -> Void)func newTextures(names: [String], scaleFactor: CGFloat, displayGamut: NSDisplayGamut, bundle: Bundle?, options: [MTKTextureLoader.Option : Any]? = nil) async throws -> [any MTLTexture]Parameters
- names:
An array of strings, each the name of a texture in an asset catalog.
- scaleFactor:
The scale factor of texture to request.
In iOS and tvOS, pass the Contentsscale value of the view where you plan to display texture content.
In macOS, pass the Backingscalefactor value of the window where you plan to display texture content.
- displayGamut:
The version of the texture based on the Gamut trait in Xcode.
To determine the appropriate parameter value, pass the widest
NSDisplayGamutvalue that returns True when queried against thecanRepresentDisplayGamut:method ofNSWindow. - bundle:
The resource bundle containing the asset catalog to load textures from.
- options:
A dictionary describing any additional texture loading steps. See
Texture Loading Options.When using this method, the texture loader ignores the Generatemipmaps, Srgb, Cubelayout, and Origin options.
- completionHandler:
A block called after all assets have been processed. See the Arraycallback signature to determine whether each texture has successfully loaded.
Discussion
See Also
Loading Textures from Asset Catalogs
newTexture(name:scaleFactor:bundle:options:)newTexture(name:scaleFactor:bundle:options:completionHandler:)newTextures(names:scaleFactor:bundle:options:completionHandler:)newTexture(name:scaleFactor:displayGamut:bundle:options:)newTexture(name:scaleFactor:displayGamut:bundle:options:completionHandler:)