INNER CODE UNIT · Rust

add_texts

CleanCut/rusty_engine · src/game.rs:203

pub fn add_texts(commands: &mut Commands, asset_server: &Res<AssetServer>, engine: &mut Engine) {
    for (_, text) in engine.texts.drain() {
        let transform = text.bevy_transform();
        let font_size = text.font_size;
        let text_string = text.value.clone();
        let font_path = text.font.clone();
        commands.spawn((
            text,
            Text2d(text_string),
            TextFont {
                font: asset_server.load(font_path),
                font_size,
                ..Default::default()
            },
            TextColor(Color::WHITE),
            TextLayout::new_with_justify(Justify::Center).with_no_wrap(),
            transform,
        ));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…