Skip to main content

Module init

Module init 

Source
Expand description

Global initialization and termination of the library.

This module provides all the plumbing required for global initialization and shutdown of godot-rust.

§Init and exit hooks

Three endpoints are automatically invoked by the engine during startup and shutdown:

All three must be present. To quickly define all three endpoints using the default names, use godot_init.

§Registering script classes

InitHandle is the registry of all your exported symbols. To register script classes, call InitHandle::add_class() or InitHandle::add_tool_class() in your godot_nativescript_init or godot_init callback:

use gdnative::prelude::*;

#[derive(NativeClass)]
struct HelloWorld { /* ... */ }

#[methods]
impl HelloWorld { /* ... */ }

fn init(handle: InitHandle) {
    handle.add_class::<HelloWorld>();
}

godot_init!(init);

Modules§

diagnostics
Run-time tracing functions to help debug the init process.

Macros§

godot_gdnative_init
Declare the API endpoint to initialize the gdnative API on startup.
godot_gdnative_terminate
Declare the API endpoint invoked during shutdown.
godot_init
Declare all the API endpoints necessary to initialize a NativeScript library.
godot_nativescript_init
Declare the API endpoint to initialize export classes on startup.

Structs§

InitHandle
A handle that can register new classes to the engine during initialization.
InitializeInfo
Context for the godot_gdnative_init callback.
TerminateInfo
Context for the godot_gdnative_terminate callback.