You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use bevy::{
prelude::*, render::camera::RenderTarget, ui::widget::ImageNodeSize, window::WindowRef,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, update)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let first_window_camera = commands.spawn((Camera3d::default(),)).id();
let image = asset_server.load("branding/icon.png");
// Spawn a second window
let second_window = commands
.spawn(Window {
title: "Second window".to_owned(),
..default()
})
.id();
let second_window_camera = commands
.spawn((
Camera2d::default(),
Camera {
target: RenderTarget::Window(WindowRef::Entity(second_window)),
..default()
},
))
.id();
commands
.spawn((Node::default(), UiTargetCamera(first_window_camera)))
.with_children(|commands| {
commands.spawn((Node::default(), ImageNode::new(image.clone())));
});
commands
.spawn((Node::default(), UiTargetCamera(second_window_camera)))
.with_children(|commands| {
commands.spawn((ImageNode::new(image.clone()),));
});
}
fn update(image_size_query: Query<Entity, Changed<ImageNodeSize>>) {
for entity in image_size_query.iter() {
println!("image size updated for {}", entity.index());
}
}
If you change the scale factor of the primary window it reports that both image sizes have been updated, even though the target scale factor only changed for the image on the primary window.
Or if you change the scale factor of the secondary window it doesn't update the image size for either image, even though the target scale factor changed for the image on the secondary window.
What went wrong
The UI image size is only updated on changes to the primary window's scale factor.
The text was updated successfully, but these errors were encountered:
Bevy version
main + 0.15
What you did
With this example:
If you change the scale factor of the primary window it reports that both image sizes have been updated, even though the target scale factor only changed for the image on the primary window.
Or if you change the scale factor of the secondary window it doesn't update the image size for either image, even though the target scale factor changed for the image on the secondary window.
What went wrong
The UI image size is only updated on changes to the primary window's scale factor.
The text was updated successfully, but these errors were encountered: