examples/prefabs/
prefab_hierarchy.rs1use crate::z_ignore_test_common::*;
2
3use flecs_ecs::prelude::*;
4fn main() {
8 let world = World::new();
9
10 let spaceship = world.prefab_named("SpaceShip");
12 world.prefab_named("Engine").child_of_id(spaceship);
13 world.prefab_named("Cockpit").child_of_id(spaceship);
14
15 let inst = world.entity_named("my_spaceship").is_a_id(spaceship);
18
19 if let Some(inst_engine) = inst.try_lookup_recursive("Engine") {
23 if let Some(inst_cockpit) = inst.try_lookup_recursive("Cockpit") {
24 println!("instance engine: {:?}", inst_engine.path().unwrap());
25 println!("instance cockpit: {:?}", inst_cockpit.path().unwrap());
26 } else {
27 println!("entity lookup failed");
28 }
29 }
30
31 }
35
36#[cfg(feature = "flecs_nightly_tests")]
37#[test]
38fn test() {
39 let output_capture = OutputCapture::capture().unwrap();
40 main();
41 output_capture.test("prefab_hierarchy".to_string());
42}