Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when using CanvasItem as the base class, the class does not appear in Godot editor picker #429

Closed
AlexOkafor opened this issue Sep 27, 2023 · 4 comments
Labels
bug c: engine Godot classes (nodes, resources, ...) status: upstream Depending on upstream fix (typically Godot)

Comments

@AlexOkafor
Copy link

Hello,

I ran across this when trying to move a base class of Node to something more specific (CanvasItem). My current workaround has been to use Control instead.

#[derive(GodotClass)]
#[class(base=CanvasItem)]
pub struct TestItem {
    #[base]
    base: Base<CanvasItem>,
}

#[godot_api]
impl CanvasItemVirtual for TestItem {
    fn init(base: Base<CanvasItem>) -> Self {
        Self { base }
    }
}

#[godot_api]
impl TestItem {}

When using the above snippet, the class doesn't appear in the godot editor. Also if I refactor a class to use CanvasItem as a base class the editor will show errors like so:

ERROR: Class 'TestItem' or its base class cannot be instantiated.
   at: (core/object/class_db.cpp:341)

I did see that CanvasItem is an abstract base class so I wasn't sure if that's related, a technical limitation of the GDext bindings, or this is working as designed w.r.t. GD extensions.

@Bromeon Bromeon added bug c: engine Godot classes (nodes, resources, ...) labels Sep 27, 2023
@Bromeon
Copy link
Member

Bromeon commented Sep 27, 2023

Thanks for reporting!

I wonder if we need to do something specific for abstract base classes 🤔 this should be possible.

@PgBiel
Copy link
Contributor

PgBiel commented Sep 29, 2023

This seems to be on the Godot side: godotengine/godot#67510 and godotengine/godot#67512

@Bromeon Bromeon added the status: upstream Depending on upstream fix (typically Godot) label Sep 29, 2023
@aaronfranke
Copy link

This is working as intended, the intention is that you are not allowed to extend abstract types. So you are not allowed to make your own CanvasItem-derived type. See the reasoning here: godotengine/godot#67510 (comment)

@Bromeon
Copy link
Member

Bromeon commented Feb 25, 2024

Thanks a lot @aaronfranke for clarifying!
Since this is an upstream design decision, I'll close this.

@Bromeon Bromeon closed this as not planned Won't fix, can't repro, duplicate, stale Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: engine Godot classes (nodes, resources, ...) status: upstream Depending on upstream fix (typically Godot)
Projects
None yet
Development

No branches or pull requests

4 participants