From 4a119dd0e1648be19d48c383119a094bad0947ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20W=C3=BCrfl?= Date: Fri, 14 Aug 2020 12:56:39 +0200 Subject: [PATCH] Add info message in UI for scene example --- examples/scene/scene.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/examples/scene/scene.rs b/examples/scene/scene.rs index 97e22563c6..9de1d2d3d4 100644 --- a/examples/scene/scene.rs +++ b/examples/scene/scene.rs @@ -13,6 +13,7 @@ fn main() { .register_component::() .add_startup_system(save_scene_system.thread_local_system()) .add_startup_system(load_scene_system.system()) + .add_startup_system(infotext_system.system()) .add_system(print_system.system()) .run(); } @@ -128,3 +129,25 @@ fn save_scene_system(_world: &mut World, resources: &mut Resources) { // TODO: save scene } + +// This is only necessary for the info message in the UI. See examples/ui/text.rs for a standalone text example. +fn infotext_system(mut commands: Commands, asset_server: Res) { + let font_handle = asset_server.load("assets/fonts/FiraSans-Bold.ttf").unwrap(); + commands + .spawn(UiCameraComponents::default()) + .spawn(TextComponents { + style: Style { + align_self: AlignSelf::FlexEnd, + ..Default::default() + }, + text: Text { + value: "Nothing to see in this window! Check the console output!".to_string(), + font: font_handle, + style: TextStyle { + font_size: 50.0, + color: Color::WHITE, + }, + }, + ..Default::default() + }); +}