Skip to content

robertcorponoi/godot_rust_helper_ext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Godot Rust Helper Extensions

This is a library of extension helper methods for godot_rust_helper.

Note: This is the extensions library used with the Rust version of godot_rust_helper and not the Node version. They will be merged at some point but in order to avoid including breaking functionality into the existing Node version, it has been separated into its own library.

Usage

To use the extensions, you open the module you want to add them to and use:

use godot_rust_helper_ext::NodeExt as _;

where NodeExt is the extension you want to use. The extensions available are listed below.

NodeExt

These extensions are tailored around working with nodes.

get_typed_node

Gets a node by its path and casts it into the expected type.

example

unsafe fn _ready(&self, owner: gdnative::Node) {
    let mut message_label: gdnative::Label = owner.get_typed_node("WinText").expect("Cannot cast to Label");
}

Acknowledgements

This extensions library was inspired after seeing an example by @ankhers that added a helper method to get a typed node in 1 line instead of the 3+ line normal method.

License

MIT