godot::obj::script

Function create_script_instance

pub unsafe fn create_script_instance<T>(
    rust_instance: T,
    for_object: Gd<<T as ScriptInstance>::Base>,
) -> *mut c_void
where T: ScriptInstance,
Expand description

Creates a new from a type that implements ScriptInstance.

See ScriptInstance for usage. Discarding the resulting value will result in a memory leak.

The exact GDExtension type of the pointer is sys::GDExtensionScriptInstancePtr, but you can treat it like an opaque pointer.

ยงSafety

The caller must ensure that for_object is not freed before passing the returned pointer back to Godot.