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

Add schematic_attr for forwarding attributes #59

Merged
merged 2 commits into from
Oct 4, 2023
Merged

Conversation

MrGVSV
Copy link
Owner

@MrGVSV MrGVSV commented Sep 17, 2023

Objective

Resolves #53

Solution

Adds the schematic_attr and asset_schematic_attr attributes to the Schematic and AssetSchematic derives, respectively. This allows attributes to be forwarded to the generated input type.

For example, take the following schematic:

#[derive(Component, Schematic, Reflect)]
#[schematic_attr(
  derive(Default),
  reflect(Default),
)]
struct MyStruct {
  #[schematic(from = u8)]
  data: u32,
  #[schematic_attr(reflect(ignore))]
  hash: u64,
}

Will now generate an input type like:

#[derive(Reflect)]
#[derive(Default)]
#[reflect(Default)]
struct MyStructInput {
  data: u8,
  #[reflect(ignore)] 
  hash: u64,
}

This also means that reflection attributes are no longer automatically passed to the input type. That behavior was removed as it would sometimes result in invalid behavior and was also not very flexible.

@MrGVSV MrGVSV merged commit a6e9509 into main Oct 4, 2023
2 checks passed
@MrGVSV MrGVSV deleted the schematic-attr branch October 4, 2023 04:42
100-TomatoJuice added a commit to 100-TomatoJuice/bevy_proto that referenced this pull request Jul 9, 2024
This reverts commit a6e9509, reversing
changes made to 6814bd5.
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

Successfully merging this pull request may close these issues.

Smart-forward reflect attributes
1 participant