godot-rust / book

Documentation and tutorials for gdext, the Rust bindings for Godot 4
Mozilla Public License 2.0
16 stars 31 forks source link

Trait `Default` is not implemented for EditorPlugin #47

Open SpencerMycek opened 4 months ago

SpencerMycek commented 4 months ago

When following the godot-rust book to create an editor plugin, the GodotClass derive macro throws an error while trying to compile

Code: Copied from Godot-rust book page on EditorPlugins

use godot::prelude::*;
use godot::engine::{EditorPlugin, IEditorPlugin};

#[derive(GodotClass)]
#[class(tool, init, editor_plugin, base=EditorPlugin)]
struct MyEditorPlugin {
    base: Base<EditorPlugin>,
}

#[godot_api]
impl IEditorPlugin for MyEditorPlugin {
    fn enter_tree(&mut self) {
        // Perform typical plugin operations here.
    }

    fn exit_tree(&mut self) {
        // Perform typical plugin operations here.
    }
}

[derive(GodotClass)]

the trait Default is not implemented for godot::prelude::Base<godot::engine::EditorPlugin>

Bromeon commented 4 months ago

Hm, I thought this is an error in the book, but it might be a proc-macro problem.

First, can you update to latest gdext master? The godot::engine module is deprecated.

And also, does the problem appear if you don't specify tool and/or editor_plugin keys, i.e.

#[derive(GodotClass)]
#[class(init, base=EditorPlugin)]
struct MyEditorPlugin {
    base: Base<EditorPlugin>,
}
SpencerMycek commented 4 months ago

My cargo.toml has this, so I believe I'm up-to-date: godot = { git = "https://github.com/godot-rust/gdext", branch = "master" }

I did not know godot::engine was deprecated, I haven't been getting warnings about that

Bromeon commented 4 months ago

You need to run cargo update from time to time, Cargo doesn't change dependencies on its own.

What about my other question? 🙂

SpencerMycek commented 4 months ago

The error I had does disappear, now I need to figure out how to change stuff from whatever old version I was in to the newest version. Is there a changelog for things? I'm not sure what to do now, since #[derive(GodotClass)] is deprecated. And following along the godot-rust book might be more difficult

Bromeon commented 4 months ago

Is there a changelog for things?

Some #announcements on Discord.

But also, did you read the deprecation messages? They contain migration info.


since #[derive(GodotClass)] is deprecated.

No, that part hasn't changed 🙂

Bromeon commented 3 months ago

@SpencerMycek any update on this? Did you manage to check with the latest version (now godot crate on crates.io)?