|
|
|
@ -78,6 +78,8 @@ fn setup_ui(mut commands: Commands) {
|
|
|
|
flex_direction: FlexDirection::Row,
|
|
|
|
flex_direction: FlexDirection::Row,
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
justify_content: JustifyContent::Start,
|
|
|
|
justify_content: JustifyContent::Start,
|
|
|
|
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
|
|
|
|
align_self: AlignSelf::Start,
|
|
|
|
column_gap: px(8),
|
|
|
|
column_gap: px(8),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -93,8 +95,8 @@ fn setup_ui(mut commands: Commands) {
|
|
|
|
|
|
|
|
|
|
|
|
commands.spawn((
|
|
|
|
commands.spawn((
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
justify_self: JustifySelf::Start,
|
|
|
|
align_self: AlignSelf::Center,
|
|
|
|
align_self: AlignSelf::Start,
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DebugState(true),
|
|
|
|
DebugState(true),
|
|
|
|
@ -104,11 +106,11 @@ fn setup_ui(mut commands: Commands) {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
children![
|
|
|
|
children![
|
|
|
|
Text::new("Outlines"),
|
|
|
|
|
|
|
|
(
|
|
|
|
(
|
|
|
|
toggle_switch((),),
|
|
|
|
DebugState(true),
|
|
|
|
observe(checkbox_self_update),
|
|
|
|
checkbox((), Spawn((Text::new("outlines"), ThemedText))),
|
|
|
|
observe(toggle_outline_state),
|
|
|
|
observe(toggle_outline_state),
|
|
|
|
|
|
|
|
observe(check_box),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -176,7 +178,7 @@ fn toggle_outline_state(
|
|
|
|
|
|
|
|
|
|
|
|
fn draw_outline_gizmos(
|
|
|
|
fn draw_outline_gizmos(
|
|
|
|
mut gizmos: Gizmos,
|
|
|
|
mut gizmos: Gizmos,
|
|
|
|
query: Query<(Entity, &GlobalTransform)>,
|
|
|
|
query: Query<(Entity, &GlobalTransform), Without<Camera>>,
|
|
|
|
meshed: Query<&Mesh2d>,
|
|
|
|
meshed: Query<&Mesh2d>,
|
|
|
|
meshes: Res<Assets<Mesh>>,
|
|
|
|
meshes: Res<Assets<Mesh>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
@ -184,9 +186,7 @@ fn draw_outline_gizmos(
|
|
|
|
let entity_center = gt.translation().truncate();
|
|
|
|
let entity_center = gt.translation().truncate();
|
|
|
|
let entity_size = gt.scale().truncate();
|
|
|
|
let entity_size = gt.scale().truncate();
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(Mesh2d(h)) = meshed.get(e) {
|
|
|
|
if let Ok(Mesh2d(h)) = meshed.get(e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mesh = meshes.get(h).unwrap();
|
|
|
|
let mesh = meshes.get(h).unwrap();
|
|
|
|
let aabb = mesh.compute_aabb().unwrap();
|
|
|
|
let aabb = mesh.compute_aabb().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
@ -198,8 +198,17 @@ fn draw_outline_gizmos(
|
|
|
|
|
|
|
|
|
|
|
|
gizmos.rect_2d(center, size, MAGENTA);
|
|
|
|
gizmos.rect_2d(center, size, MAGENTA);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let size = Vec2::new(SCALE / 2.0, SCALE / 2.0);
|
|
|
|
let size = SCALE * 0.6;
|
|
|
|
gizmos.cross_2d(entity_center, size, MAGENTA);
|
|
|
|
gizmos.cross_2d(entity_center, size, MAGENTA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn check_box(change: On<ValueChange<bool>>, mut commands: Commands) {
|
|
|
|
|
|
|
|
let mut checkbox = commands.entity(change.source);
|
|
|
|
|
|
|
|
if change.value {
|
|
|
|
|
|
|
|
checkbox.insert(Checked);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
checkbox.remove::<Checked>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|