What problem does this solve or what need does it fill?
You will still need to pass a handle from outside or add it manually in template(...).
pub fn demo(atlas: Handle<TextureAtlasLayout>) -> impl Scene {
bsn! {
ImageNode {
image: "images/button.png",
texture_atlas: { TextureAtlasTemplate {
layout: HandleTemplate::Handle(atlas.clone()),
index: 0,
}},
}
}
}
// or
pub fn demo2() -> impl Scene {
bsn! {
template(|ctx| {
Ok(ImageNode {
image: ctx.resource::<AssetServer>().load("images/button.png"),
texture_atlas: Some(TextureAtlas {
layout: ctx.resource_mut::<Assets<TextureAtlasLayout>>().add(
TextureAtlasLayout::from_grid(UVec2::new(65, 12), 1, 3, None, None)
),
index: 0,
}),
..default()
})
})
}
}
Allowing create a handle in-place when authoring a scene function. It is more ergonomic to compose related data of one component.
What solution would you like?
Add a HandleTemplate::Insert(...) to create a handle directly from value.
pub fn demo() -> impl Scene {
bsn! {
ImageNode {
image: "images/button.png",
texture_atlas: { TextureAtlasTemplate {
layout: HandleTemplate::Insert(TextureAtlasLayout::from_grid(UVec2::new(65, 12), 1, 3, None, None)),
index: 0,
}},
}
}
}
Additional context
This may also works when composing a bsn file, I think.
What problem does this solve or what need does it fill?
You will still need to pass a handle from outside or add it manually in
template(...).Allowing create a handle in-place when authoring a scene function. It is more ergonomic to compose related data of one component.
What solution would you like?
Add a
HandleTemplate::Insert(...)to create a handle directly from value.Additional context
This may also works when composing a bsn file, I think.