Type Method

sceneWithURL:options:error:

Loads a scene from the specified URL.

Declaration

+ (instancetype)sceneWithURL:(NSURL *)url options:(NSDictionary<SCNSceneSourceLoadingOption, id> *)options error:(NSError * _Nullable *)error;

Parameters

url

The URL to the scene file to load.

options

A dictionary of options affecting scene loading, or nil for default options. For available keys, see Scene Loading Options.

error

If an error occurs, this pointer is set to an NSError object describing the error. If you do not want error information, pass in nil.

Return Value

A new scene object, or nil if no scene could be loaded.

Discussion

This method provides a convenient way to load a complete scene from a file at an arbitrary URL. For more detailed options or to load only part of a file’s scene graph, use the SCNSceneSource class.

When creating a scene using Xcode's Scene Editor or an external tool, you should copy your scene file into a directory with the .scnassets extension inside your app bundle. You should also place any image files referenced as textures from that scene in an Asset Catalog. Xcode will optimize the scene and texture resources for best performance on each target device, and prepare your texture resources for delivery features such as App Thinning and On-Demand Resources.

See Also

Creating a Scene from a File

+ scene

Creates and returns an empty scene.

+ sceneNamed:

Loads a scene from a file with the specified name in the app’s main bundle.

+ sceneNamed:inDirectory:options:

Loads a scene from a file with the specified name in a specific subdirectory of the app’s main bundle.