diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 287c9f958d..f5b1412386 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -333,6 +333,8 @@ with UI components as a child of an entity without UI components, your UI layout let physical_scroll_position = clamped_scroll_position.floor(); + node.bypass_change_detection().scroll_offset = physical_scroll_position; + for child_uinode in ui_children.iter_ui_children(entity) { update_uinode_geometry_recursive( commands, diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 6ffedfb45f..b520675eca 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -46,6 +46,10 @@ pub struct ComputedNode { /// /// Automatically calculated by [`super::layout::ui_layout_system`]. pub scrollbar_size: Vec2, + /// Offset of scrolled content + /// + /// Automatically calculated by [`super::layout::ui_layout_system`]. + pub scroll_offset: Vec2, /// The width of this node's outline. /// If this value is `Auto`, negative or `0.` then no outline will be rendered. /// Outline updates bypass change detection. @@ -310,6 +314,7 @@ impl ComputedNode { size: Vec2::ZERO, content_size: Vec2::ZERO, scrollbar_size: Vec2::ZERO, + scroll_offset: Vec2::ZERO, outline_width: 0., outline_offset: 0., unrounded_size: Vec2::ZERO,