Allow alternate templates for properties
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 4d 8m
- Merged PRs (30d)
- 147
Description
## What problem does this solve or what need does it fill?
I want to use an alternate template for `Handle`s that clone handles from a pre-loaded AssetCollection. My ideal API would look something like this:
```rust
fn scene(text: &str, size: Val) -> impl Scene {
bsn![
Text2d(text)
TextFont {
font: api_macro_that_returns_a_template_for_asset_handle!(MyCollection::font_a),
font_size: size,
}
]
}
#[derive(Resource)]
struct MyCollection {
font_a: Handle,
}
```
## What solution would you like?
I'd like to be able to use an alternate template for properties, not just the whole `Component`.
## What alternative(s) have you considered?
I could have the macro return a template for the whole component, but this would mean a lot of code duplication as I'd need a separate macro for every component that contains a `Handle`.
## Additional context
I am hoping to use this with the `AssetCollection` from [`bevy_asset_loader`](https://docs.rs/bevy_asset_loader/latest/bevy_asset_loader/) crate.
Contributor guide
Research direction
Start with the bsn! macro entry point and the handling of Handle properties, then review how alternate templates are currently applied to whole components. Done means a property-level template API can clone handles from a pre-loaded AssetCollection without requiring a separate whole-component template for each component.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100