-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Open
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior
Description
Bevy version
0.5
Operating system & version
Tested on Linux, but probably affects all other systems
What you did
I have this system that resizes for all the cameras with OrthographicsProjection and CameraAspectRatio compoents:
pub enum CameraAspectRatio {
Auto {
min_width: f32,
min_height: f32,
},
FixedWidth(f32),
FixedHeight(f32),
}
pub fn camera_aspect_ratio(
windows: Res<Windows>,
mut query:
Query<(&mut OrthographicProjection, &Camera, &CameraAspectRatio)>,
) {
for (mut projection, camera, ratio) in query.iter_mut() {
if let (ScalingMode::None, Some(window)) =
(&projection.scaling_mode, windows.get(camera.window))
{
let window_size = Vec2::new(window.width(), window.height());
let size = match *ratio {
CameraAspectRatio::Auto { min_width, min_height } => if
window_size.x / window_size.y > min_width / min_height
{
Vec2::new(
min_height * window_size.x / window_size.y,
min_height,
)
} else {
Vec2::new(
min_width, min_width * window_size.y / window_size.x,
)
},
CameraAspectRatio::FixedWidth(width) => Vec2::new(
width,
width * window_size.y / window_size.x,
),
CameraAspectRatio::FixedHeight(height) => Vec2::new(
height * window_size.x / window_size.y,
height,
),
};
match projection.window_origin {
WindowOrigin::Center => {
projection.left = -size.x / 2.0;
projection.right = size.x / 2.0;
projection.bottom = -size.y / 2.0;
projection.top = size.y / 2.0;
},
WindowOrigin::BottomLeft => {
projection.left = 0.0;
projection.right = size.x;
projection.bottom = 0.0;
projection.top = size.y;
},
}
}
}
}The system works fine and the game itself displays correctly. However when I try to create a root node with size set to 100% by 100% it does not fill the whole window, but instead its virtual size gets limited to the value of the real screen size:
commands
.spawn_bundle(NodeBundle {
material: materials.add(Color::rgba(1.0, 1.0, 1.0, 0.5).into()),
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
flex_direction: FlexDirection::Row,
align_items: AlignItems::FlexEnd,
justify_content: JustifyContent::SpaceBetween,
..Default::default()
},
..Default::default()
})What you expected to happen
The root node should fill the whole window.
What actually happened
The root node's size was limited to the window's logical size and was not enough to fill the virtual camera size (1920 by 1080)
Metadata
Metadata
Assignees
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior
