Crates.io | godot_egui |
lib.rs | godot_egui |
version | 0.1.8 |
source | src |
created_at | 2021-07-23 10:33:26.61841 |
updated_at | 2021-09-01 13:43:50.201458 |
description | Egui backend for the Godot Engine |
homepage | https://github.com/setzer22/godot-egui |
repository | https://github.com/setzer22/godot-egui |
max_upload_size | |
id | 426233 |
size | 23,759 |
An egui backend for godot-rust.
Godot has a perfectly valid GUI system, so why egui
? Here are my personal reasons:
egui
's widgets only rely on a small set of themable properties.egui
is far more simple.These are minimal usage instructions. See the example project in ./example_project/
for a more advanced project.
First, import the godot_egui
crate as a library in your project.
Cargo.toml
[dependencies]
# ...
egui = "0.13"
godot_egui = "0.1.1"
Next, register the custom Godot classes declared in godot_egui
:
Somewhere in your lib.rs
fn init(handle: InitHandle) {
godot_egui::register_classes(handle);
}
godot_init!(init);
You will also need to create a .gdns
script and attach it to a Control
-derived node.
GodotEgui.gdns
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://godot_egui.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "GodotEgui"
class_name = "GodotEgui"
library = ExtResource( 1 )
Finally, get a reference to that node as a RefInstance<GodotEgui, Shared>
in your code and do this to draw the GUI using:
let gui : RefInstance<GodotEgui, Shared> = ...;
gui.map_mut(|gui, instance| {
gui.update(instance, None, |ui| {
ui.label("Hello world!");
});
})
The draw code needs to be run constantly, so you should call it from a _process
callback or similar.
Should be as simple as:
cargo build
Egui supports setting custom fonts out of the box:
Additionally, godot-egui supports registering custom fonts by directly from the Godot editor by exposing several script properties.
The fonts will be loaded into the egui::FontFamily::Proportional
family in order. If you don't want egui's default fonts, the override_default_fonts
boolean can be set so that only Custom fonts get loaded.
The project is in a very early release stage. Breaking changes may occur, but only when absolutely necessary.
This integration is being used in my own project, The Process.
If you use this library and enjoy it, please feel free to submit a PR and I will add it to the list!
godot-rust