bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Wrong Ui Node Position when using Val::Percent with bigger UiScale

Open pablo-lua opened this issue 2 years ago • 0 comments

Bevy version

886a256

What you did

Spawned a NodeBundle with some values based on Percent.

  commands.spawn(NodeBundle {
      style: Style {
          position_type: PositionType::Absolute,
          height: Val::Percent(50.),
          width: Val::Percent(50.),
          right: Val::Percent(0.),
          ..Default::default()
      },
      background_color: BackgroundColor(Color::WHITE),
      ..Default::default()
  });

What went wrong

The size is not as expected, for example, if I have Style::right as Val::Percent(0.), I expect that the Node were in the border of the window

Result images with different `UiScale` (The number at the bottom is the actual scale)

image image image image

Additional information

This is related to how the ui_layout_system round the Positions, together with the fact that the Camera is also transformed by the scale, causes a situation where the rounding causes big gaps. Also related to #11207

pablo-lua avatar Jan 27 '24 20:01 pablo-lua