1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69use super::prelude::*;
pub fn text_system(
mut commands: Commands,
font: Res<MyFont>,
object_info: Res<SelectedObjectInformation>,
texts: Query<Entity, With<ObjectText>>,
) {
for text in texts.iter() {
commands.entity(text).despawn();
}
for (i, info) in object_info.info.iter().enumerate() {
//println!("POS: {}", (i as f32 * 20.0) );
commands.spawn((
// Create a TextBundle that has a Text with a single section.
TextBundle::from_section(
// Accepts a `String` or any type that converts into a `String`, such as `&str`
info,
TextStyle { font: font.0.clone(), ..default() },
) // Set the alignment of the Text
.with_text_alignment(TextAlignment::Left)
// Set the style of the TextBundle itself.
.with_style(Style {
position_type: PositionType::Absolute,
bottom: Val::Px(45.0 + (i as f32 * 20.0)),
left: Val::Px(15.0),
..default()
}),
ObjectText,
));
}
}
pub fn text_update_system(
mut query: Query<&mut Text, With<FpsText>>
) {
for mut text in &mut query {
text.sections[1].value = "ZZZZZZ".to_string();
// if let Some(fps) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) {
// if let Some(value) = fps.smoothed() {
// // Update the value of the second section
// text.sections[1].value = format!("{value:.2}");
// }
// }
}
}
#[derive(Component)]
pub struct ObjectText;
#[derive(Component)]
pub struct FpsText;
#[derive(Component)]
struct AnimateTranslation;
#[derive(Component)]
struct AnimateRotation;
#[derive(Component)]
struct AnimateScale;
pub fn text_test(
) {
}