Skip to main content

Singleton

Trait Singleton 

pub trait Singleton: GodotClass {
    // Required method
    fn singleton() -> Gd<Self>;
}
Expand description

Trait for singleton classes in Godot.

There is only one instance of each singleton class in the engine, accessible through singleton().

Required Methods§

fn singleton() -> Gd<Self>

Returns the singleton instance.

§Panics

If called during global init/deinit of godot-rust, and the singleton in question is not yet available. You can check this with init::is_singleton_available::<Self>(). See also ExtensionLibrary.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§