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

One (or more) built-in components (E.g. IsDefaultUiCamera) can't be used with "require" #17052

Closed
kim-fg opened this issue Dec 30, 2024 · 3 comments · Fixed by #17139
Closed
Labels
A-Cross-Cutting Impacts the entire engine A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@kim-fg
Copy link

kim-fg commented Dec 30, 2024

Bevy version

0.15.0

[Optional] Relevant system information

N/A

What you did

Tried to use IsDefaultUiCamera with the new require(component) system. Adapted from code in the official UI example.

#[derive(Component, Default)]
#[require(Camera2d, IsDefaultUiCamera)] // <- error here
struct MenuCamera;

What went wrong

IsDefaultUiCamera doesnt implement default. This is something bevy should always do when components can be "required" in my opinion. The IsDefaultUiCamera component is a unit-like struct, so there is no data to attach either.

Additional information

This is mostly a reminder/todo for myself. It's a small thing to fix, but I'm sure there are other components that need the same sort of attention. I'm also fairly sure this may be a dupe, but with 2k+ issues I don't want to spend the time to find it.

Feel free to link a dupe if you know one, this feels like something that could be an overarching issue and the more components that can be fixed in a single commit the better imo.

If someone wants to fix this, thanks in advance!

@kim-fg kim-fg added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 30, 2024
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy A-Rendering Drawing game state to the screen A-Cross-Cutting Impacts the entire engine S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! and removed S-Needs-Triage This issue needs to be labelled labels Dec 30, 2024
@alice-i-cecile
Copy link
Member

@BD103 this seems like a great lint candidate!

@BD103
Copy link
Member

BD103 commented Jan 2, 2025

@BD103 this seems like a great lint candidate!

Interesting! Is the idea to recommend all Components implement Default, or is there some more specific criteria for the lint?

@alice-i-cecile
Copy link
Member

All unit structs that impl Component should impl Default :)

github-merge-queue bot pushed a commit that referenced this issue Jan 5, 2025
Derived `Default` for all public unit structs that already derive from
`Component`. This allows them to be used more easily as required
components.
To avoid clutter in tests/examples, only public components were
affected, but this could easily be expanded to affect all unit
components.

Fixes #17052.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Cross-Cutting Impacts the entire engine A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants