@@ -70,13 +70,27 @@ pub struct UiPlugin;
7070/// The label enum labeling the types of systems in the Bevy UI
7171#[ derive( Debug , Hash , PartialEq , Eq , Clone , SystemSet ) ]
7272pub enum UiSystem {
73- /// After this label, the ui layout state has been updated
74- Layout ,
75- /// After this label, input interactions with UI entities have been updated for this frame
73+ /// After this label, input interactions with UI entities have been updated for this frame.
74+ ///
75+ /// Runs in [`PreUpdate`].
7676 Focus ,
77- /// After this label, the [`UiStack`] resource has been updated
77+ /// All UI systems in [`PostUpdate`] will run in or after this label.
78+ Prepare ,
79+ /// After this label, the ui layout state has been updated.
80+ ///
81+ /// Runs in [`PostUpdate`].
82+ Layout ,
83+ /// UI systems ordered after [`UiSystem::Layout`].
84+ ///
85+ /// Runs in [`PostUpdate`].
86+ PostLayout ,
87+ /// After this label, the [`UiStack`] resource has been updated.
88+ ///
89+ /// Runs in [`PostUpdate`].
7890 Stack ,
79- /// After this label, node outline widths have been updated
91+ /// After this label, node outline widths have been updated.
92+ ///
93+ /// Runs in [`PostUpdate`].
8094 Outlines ,
8195}
8296
@@ -129,6 +143,15 @@ impl Plugin for UiPlugin {
129143 . register_type :: < widget:: Label > ( )
130144 . register_type :: < ZIndex > ( )
131145 . register_type :: < Outline > ( )
146+ . configure_sets (
147+ PostUpdate ,
148+ (
149+ UiSystem :: Prepare . before ( UiSystem :: Stack ) ,
150+ UiSystem :: Layout ,
151+ ( UiSystem :: PostLayout , UiSystem :: Outlines ) ,
152+ )
153+ . chain ( ) ,
154+ )
132155 . add_systems (
133156 PreUpdate ,
134157 ui_focus_system. in_set ( UiSystem :: Focus ) . after ( InputSystem ) ,
@@ -138,16 +161,14 @@ impl Plugin for UiPlugin {
138161 PostUpdate ,
139162 (
140163 check_visibility :: < WithNode > . in_set ( VisibilitySystems :: CheckVisibility ) ,
141- update_target_camera_system. before ( UiSystem :: Layout ) ,
142- apply_deferred
143- . after ( update_target_camera_system)
144- . before ( UiSystem :: Layout ) ,
164+ ( update_target_camera_system, apply_deferred)
165+ . chain ( )
166+ . in_set ( UiSystem :: Prepare ) ,
145167 ui_layout_system
146168 . in_set ( UiSystem :: Layout )
147169 . before ( TransformSystem :: TransformPropagate ) ,
148170 resolve_outlines_system
149171 . in_set ( UiSystem :: Outlines )
150- . after ( UiSystem :: Layout )
151172 // clipping doesn't care about outlines
152173 . ambiguous_with ( update_clipping_system)
153174 . in_set ( AmbiguousWithTextSystem ) ,
@@ -164,14 +185,14 @@ impl Plugin for UiPlugin {
164185 // its own UiImage, and `widget::text_system` & `bevy_text::update_text2d_layout`
165186 // will never modify a pre-existing `Image` asset.
166187 widget:: update_image_content_size_system
167- . before ( UiSystem :: Layout )
188+ . in_set ( UiSystem :: Prepare )
168189 . in_set ( AmbiguousWithTextSystem )
169190 . in_set ( AmbiguousWithUpdateText2DLayout ) ,
170191 (
171192 texture_slice:: compute_slices_on_asset_event,
172193 texture_slice:: compute_slices_on_image_change,
173194 )
174- . after ( UiSystem :: Layout ) ,
195+ . in_set ( UiSystem :: PostLayout ) ,
175196 ) ,
176197 ) ;
177198
@@ -203,7 +224,7 @@ fn build_text_interop(app: &mut App) {
203224 PostUpdate ,
204225 (
205226 widget:: measure_text_system
206- . before ( UiSystem :: Layout )
227+ . in_set ( UiSystem :: Prepare )
207228 // Potential conflict: `Assets<Image>`
208229 // In practice, they run independently since `bevy_render::camera_update_system`
209230 // will only ever observe its own render target, and `widget::measure_text_system`
@@ -217,7 +238,7 @@ fn build_text_interop(app: &mut App) {
217238 // FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
218239 . ambiguous_with ( widget:: update_image_content_size_system) ,
219240 widget:: text_system
220- . after ( UiSystem :: Layout )
241+ . in_set ( UiSystem :: PostLayout )
221242 . after ( bevy_text:: remove_dropped_font_atlas_sets)
222243 // Text2d and bevy_ui text are entirely on separate entities
223244 . ambiguous_with ( bevy_text:: update_text2d_layout) ,
0 commit comments