Merge pull request #181 from BafDyce/169-scene-example-ui-info-msg

Add info message in UI for scene example
This commit is contained in:
Carter Anderson 2020-08-14 12:35:50 -07:00 committed by GitHub
commit 9d7981607f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,7 @@ fn main() {
.register_component::<ComponentB>()
.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<AssetServer>) {
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()
});
}