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

Read only fields in resources #213

Open
AlexAegis opened this issue Aug 18, 2024 · 1 comment
Open

Read only fields in resources #213

AlexAegis opened this issue Aug 18, 2024 · 1 comment

Comments

@AlexAegis
Copy link

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
Copy link
Owner

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.

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