jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.21k stars 174 forks source link

Read only fields in resources #213

Open AlexAegis opened 2 months ago

AlexAegis commented 2 months ago

I tried going through the crate, and even seen an older changelog entry where read_only(?) was added but I cannot figure out how to mark a field in a resource as read only.

This is what I tried to do:

#[derive(Resource, Debug, Default, Deref, DerefMut, Reflect, InspectorOptions)]
#[reflect(Resource, InspectorOptions)]
pub struct MyResource {
    #[inspector(read_only)]
    foo: bool,
}

To just display a field but not let it be changed from the inspector. Is this supported? I saw that InspectorPrimitive requires you to implement readonly variants of the ui too so I assumed there's some config option to mark fields as readonly.

jakobhellermann commented 1 month ago

I think that was from way back when Inspectable was a custom derive, instead of using bevy's reflect functionality.

Currently you can only display everything read-only (ui_for_reflect_readonly), not set a single field to be displayed readonly.