nightshade 0.57.0

A cross-platform data-oriented game engine.
Documentation
use crate::ecs::text::components::TextProperties;
use crate::ecs::world::{Entity, Vec2, World};

pub fn spawn_ui_text(world: &mut World, text: impl Into<String>, _position: Vec2) -> Entity {
    let text_index = world
        .res_mut::<crate::ecs::text::resources::TextState>()
        .cache
        .add_text(text);
    world.spawn_with((crate::ecs::text::components::Text::new(text_index),))
}

pub fn spawn_ui_text_with_properties(
    world: &mut World,
    text: impl Into<String>,
    _position: Vec2,
    properties: TextProperties,
) -> Entity {
    let text_index = world
        .res_mut::<crate::ecs::text::resources::TextState>()
        .cache
        .add_text(text);
    let mut text_component = crate::ecs::text::components::Text::new(text_index);
    text_component.properties = properties;
    world.spawn_with((text_component,))
}