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

Resources missing from resource panel #94

Closed
blueforesticarus opened this issue Jan 27, 2024 · 4 comments
Closed

Resources missing from resource panel #94

blueforesticarus opened this issue Jan 27, 2024 · 4 comments

Comments

@blueforesticarus
Copy link

blueforesticarus commented Jan 27, 2024

I can't seem to figure out how to get my custom resource to show up in the panel. I've tried deriving Reflect based on reading the resource panel code, but to no avail.

What I have:

use bevy::prelude::*;
use bevy_editor_pls::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(EditorPlugin::default())
        .add_systems(Startup, setup)
        .add_systems(Update, keyboard_input_system)
        //.init_resource::<Speed>()
        .insert_resource(Speed { s: 0.5 })
        .run();
}

#[derive(Resource, Reflect, Debug, Clone, Copy)]
pub struct Speed {
    pub s: f32,
}

...

But Speed still does not show up in the resource panel.

@jakobhellermann
Copy link
Owner

You're missing app.register_type::<Speed>(). Also I think the inspector only shows types that have #[reflect(Resource)] below the derive but I'm not 100% sure right now.

@blueforesticarus
Copy link
Author

blueforesticarus commented Jan 27, 2024

Yup. Needed both of those. Gracias

Working:

use bevy::prelude::*;
use bevy_editor_pls::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(EditorPlugin::default())
        .add_systems(Startup, setup)
        .add_systems(Update, keyboard_input_system)
        //.init_resource::<Speed>()
        .insert_resource(Speed { s: 0.5 })
        .register_type::<Speed>() //HERE
        .run();
}

#[derive(Resource, Reflect)]
#[reflect(Resource)] //HERE
pub struct Speed {
    pub s: f32,
}

@blueforesticarus
Copy link
Author

semi-relevant open bevy issue bevyengine/bevy#3936

@jakobhellermann
Copy link
Owner

Also I think bevy_inspector_egui could technically display all registered resources, regardless of whether they have reflect(Resource). I'm not sure if that would be better, maybe it's good to be explicit about that, and I think things like resources in scenes need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants