ITADN

How to pass a font asset handle to a style builder?

#29Openmusjj 创建于 2024-09-09
M
musjjcommented
I'm trying to pass a handle: ```rust #[derive(Clone, PartialEq)] pub struct MyUi; impl ViewTemplate for MyUi { type View = impl View; fn create(&self, cx: &mut Cx) -> Self::View { let font_assets = cx.use_resource::<MyFontAssets>(); let font = font_assets.comic_sans.clone(); Element::<NodeBundle>::new().style(move |ss: &mut StyleBuilder| { ss.font(font); }) } } ``` But it doesn't work because the style builder function must be `Fn`: ``` expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` required for `{closure@src/my_ui.rs:26:44: 26:72}` to implement `bevy_mod_stylebuilder::StyleTuple` ``` Is there a way to make font handles work with quill?
4 条评论