GDNativeLibrary

Inherits: Resource < Reference < Object

An external library containing functions or script classes to use in Godot.

Description

A GDNative library can implement NativeScripts, global functions to call with the GDNative class, or low-level engine extensions through interfaces such as ARVRInterfaceGDNative. The library must be compiled for each platform and architecture that the project will run on.

Tutorials

Properties

ConfigFile

config_file

bool

load_once

true

bool

reloadable

true

bool

singleton

false

String

symbol_prefix

"godot_"

Methods

PoolStringArray

get_current_dependencies ( ) const

String

get_current_library_path ( ) const


Property Descriptions

ConfigFile config_file

This resource in INI-style ConfigFile format, as in .gdnlib files.


bool load_once = true

  • void set_load_once ( bool value )

  • bool should_load_once ( )

If true, Godot loads only one copy of the library and each script that references the library will share static data like static or global variables.

If false, Godot loads a separate copy of the library into memory for each script that references it.


bool reloadable = true

  • void set_reloadable ( bool value )

  • bool is_reloadable ( )

If true, the editor will temporarily unload the library whenever the user switches away from the editor window, allowing the user to recompile the library without restarting Godot.

Note: If the library defines tool scripts that run inside the editor, reloadable must be false. Otherwise, the editor will attempt to unload the tool scripts while they're in use and crash.


bool singleton = false

  • void set_singleton ( bool value )

  • bool is_singleton ( )

If true, Godot loads the library at startup rather than the first time a script uses the library, calling {prefix}gdnative_singleton after initializing the library (where {prefix} is the value of symbol_prefix). The library remains loaded as long as Godot is running.

Note: A singleton library cannot be reloadable.


String symbol_prefix = "godot_"

  • void set_symbol_prefix ( String value )

  • String get_symbol_prefix ( )

The prefix this library's entry point functions begin with. For example, a GDNativeLibrary would declare its gdnative_init function as godot_gdnative_init by default.

On platforms that require statically linking libraries (currently only iOS), each library must have a different symbol_prefix.


Method Descriptions

PoolStringArray get_current_dependencies ( ) const

Returns paths to all dependency libraries for the current platform and architecture.


String get_current_library_path ( ) const

Returns the path to the dynamic library file for the current platform and architecture.