Skip to main content

load_threaded

Function load_threaded 

pub async fn load_threaded<T>(path: impl AsArg<GString>) -> Gd<T>
where T: Inherits<Resource>,
Available on crate feature experimental-threads only.
Expand description

⚠️ Loads a resource from the filesystem located at path on a worker thread, panicking on error.

See try_load() and try_load_threaded() for more information.

§Example

use godot::prelude::*;

godot::task::spawn(async {
    let scene = load_threaded::<PackedScene>("res://path/to/Main.tscn").await;
});

§Panics

If the resource cannot be loaded, is not of type T or inherited or the global MainLoop is not a SceneTree.