Open
Description
Given the class
#[derive(GodotClass)]
#[class(base=CharacterBody2D, init, tool)]
pub struct Player {
base: Base<CharacterBody2D>,
#[init(val = 1)]
x: i8,
}
#[godot_api]
impl ICharacterBody2D for Player {
// Or enter_tree, it don't make a different
fn ready(&mut self) {
self.x = 0;
}
fn process(&mut self, _: f64) {
godot_print!("{}", self.x);
}
}
One would expect the console to spit out 0
all the time right? Well that would only be true when the scene is first opened, because if any change triggers hot reload x
will be reset to 1
as if ready
was never run.
This might not seem like a big deal, until you test this with something like
#[derive(GodotClass)]
#[class(base=CharacterBody2D, init, tool)]
pub struct Player {
base: Base<CharacterBody2D>,
#[init(val = None)]
camera: Option<Gd<Camera2D>>,
}
This also applies for properties initialized with OnReady
, so hot reload + tool is pretty much a no go