Display the bounds of each text node in the text_debug ui example (#15622)
# Objective Add a background colour to each text node in the `text_debug` example to visualize their bounds. ## Showcase <img width="961" alt="deb" src="https://github.com/user-attachments/assets/deec3e15-b0f0-411f-9af1-597587ac2a83"> In the bottom right you can see the empty space at the bottom of the text node, making it much more obvious that there is a bug causing the size of the bounds to be calculated incorrectly.
This commit is contained in:
parent
0b5a360585
commit
92f39354a3
@ -31,7 +31,9 @@ struct TextChanges;
|
||||
|
||||
fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
let font = asset_server.load("fonts/FiraSans-Bold.ttf");
|
||||
let background_color = MAROON.into();
|
||||
commands.spawn(Camera2d);
|
||||
|
||||
let root_uinode = commands
|
||||
.spawn(NodeBundle {
|
||||
style: Style {
|
||||
@ -64,6 +66,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
..default()
|
||||
},
|
||||
)
|
||||
.with_background_color(background_color)
|
||||
);
|
||||
builder.spawn(TextBundle::from_section(
|
||||
"This text is right-justified. The `JustifyText` component controls the horizontal alignment of the lines of multi-line text relative to each other, and does not affect the text node's position in the UI layout.", TextStyle {
|
||||
@ -77,6 +80,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
max_width: Val::Px(300.),
|
||||
..default()
|
||||
})
|
||||
.with_background_color(background_color)
|
||||
);
|
||||
builder.spawn(
|
||||
TextBundle::from_section(
|
||||
@ -91,6 +95,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
max_width: Val::Px(300.),
|
||||
..default()
|
||||
})
|
||||
.with_background_color(background_color)
|
||||
);
|
||||
}).id();
|
||||
|
||||
@ -119,6 +124,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
max_width: Val::Px(400.),
|
||||
..default()
|
||||
})
|
||||
.with_background_color(background_color)
|
||||
);
|
||||
|
||||
builder.spawn(
|
||||
@ -134,7 +140,8 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
.with_style(Style {
|
||||
max_width: Val::Px(300.),
|
||||
..default()
|
||||
}),
|
||||
})
|
||||
.with_background_color(background_color)
|
||||
);
|
||||
|
||||
builder.spawn(
|
||||
@ -150,7 +157,8 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
.with_style(Style {
|
||||
max_width: Val::Px(300.),
|
||||
..default()
|
||||
}),
|
||||
})
|
||||
.with_background_color(background_color)
|
||||
);
|
||||
|
||||
builder.spawn((
|
||||
@ -221,12 +229,11 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
color: BLUE.into(),
|
||||
},
|
||||
),
|
||||
]),
|
||||
]).with_background_color(background_color),
|
||||
TextChanges,
|
||||
));
|
||||
})
|
||||
.id();
|
||||
|
||||
commands
|
||||
.entity(root_uinode)
|
||||
.add_children(&[left_column, right_column]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user