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

Custom mainloop can't work #58

Closed
hapenia opened this issue Jan 1, 2023 · 4 comments
Closed

Custom mainloop can't work #58

hapenia opened this issue Jan 1, 2023 · 4 comments
Labels
bug status: upstream Depending on upstream fix (typically Godot)

Comments

@hapenia
Copy link
Contributor

hapenia commented Jan 1, 2023

Custom mainloop can't work properly. Refers to this issue. kleonc's solution can work with gdscript mainloop, but rust's failed.

The minimal reproduction project is in the linked issue above. And the rust part is simply add these:

Here is my_main_loop.rs:

use godot::prelude::*;

#[derive(GodotClass, Debug)]
#[class(base=SceneTree)]
pub struct MyMainLoop {
    #[base]
    base: Base<SceneTree>,
}

#[godot_api]
impl MyMainLoop {
    #[func]
    fn say_hello(&self) {
        godot::prelude::godot_print!("hello world!");
    }
}

#[godot_api]
impl GodotExt for MyMainLoop {

}

Here lib.rs:

use godot::prelude::*;

struct ExtMain;

mod my_mainloop;

#[gdextension]
unsafe impl ExtensionLibrary for ExtMain {}
@hapenia
Copy link
Contributor Author

hapenia commented Jan 1, 2023

My guess is that there was something wrong in the class registration or binding process.

@Bromeon Bromeon added bug status: upstream Depending on upstream fix (typically Godot) labels Jan 24, 2023
@Bromeon
Copy link
Member

Bromeon commented Jan 24, 2023

Just to clarify: there is nothing that godot-rust could do here, right?
We need to wait for an fix in Godot itself?

@Bromeon
Copy link
Member

Bromeon commented Feb 5, 2023

@Hapenia-Lans any answer to my question above? 🙂

@hapenia
Copy link
Contributor Author

hapenia commented Feb 19, 2023

Closed. Something went wrong if you don't override init() function. Add the code below can fix this. Maybe it should be another issue.

#[godot_api]
impl GodotExt for MyMainLoop {
    fn init(base: Base<SceneTree>) -> Self {
        Self { base }
    }
}

@hapenia hapenia closed this as completed Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status: upstream Depending on upstream fix (typically Godot)
Projects
None yet
Development

No branches or pull requests

2 participants