nightshade 0.8.0

A cross-platform data-oriented game engine.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use super::{ComponentInspector, InspectorContext, impl_simple_inspector};
use crate::prelude::*;

fn add_name(world: &mut World, entity: Entity) {
    world.set_name(entity, Name("New Entity".to_string()));
}

fn name_ui(world: &mut World, entity: Entity, ui: &mut egui::Ui, _context: &mut InspectorContext) {
    if let Some(Name(name)) = world.get_name_mut(entity) {
        ui.label("Name");
        ui.text_edit_singleline(name);
    }
}

impl_simple_inspector!(NameInspector, "Name", entity_has_name, remove_name, name_ui, custom_add => add_name);