@@ -70,13 +70,27 @@ pub struct UiPlugin;
70
70
/// The label enum labeling the types of systems in the Bevy UI
71
71
#[ derive( Debug , Hash , PartialEq , Eq , Clone , SystemSet ) ]
72
72
pub 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`].
76
76
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`].
78
90
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`].
80
94
Outlines ,
81
95
}
82
96
@@ -129,6 +143,15 @@ impl Plugin for UiPlugin {
129
143
. register_type :: < widget:: Label > ( )
130
144
. register_type :: < ZIndex > ( )
131
145
. 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
+ )
132
155
. add_systems (
133
156
PreUpdate ,
134
157
ui_focus_system. in_set ( UiSystem :: Focus ) . after ( InputSystem ) ,
@@ -138,16 +161,14 @@ impl Plugin for UiPlugin {
138
161
PostUpdate ,
139
162
(
140
163
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 ) ,
145
167
ui_layout_system
146
168
. in_set ( UiSystem :: Layout )
147
169
. before ( TransformSystem :: TransformPropagate ) ,
148
170
resolve_outlines_system
149
171
. in_set ( UiSystem :: Outlines )
150
- . after ( UiSystem :: Layout )
151
172
// clipping doesn't care about outlines
152
173
. ambiguous_with ( update_clipping_system)
153
174
. in_set ( AmbiguousWithTextSystem ) ,
@@ -164,14 +185,14 @@ impl Plugin for UiPlugin {
164
185
// its own UiImage, and `widget::text_system` & `bevy_text::update_text2d_layout`
165
186
// will never modify a pre-existing `Image` asset.
166
187
widget:: update_image_content_size_system
167
- . before ( UiSystem :: Layout )
188
+ . in_set ( UiSystem :: Prepare )
168
189
. in_set ( AmbiguousWithTextSystem )
169
190
. in_set ( AmbiguousWithUpdateText2DLayout ) ,
170
191
(
171
192
texture_slice:: compute_slices_on_asset_event,
172
193
texture_slice:: compute_slices_on_image_change,
173
194
)
174
- . after ( UiSystem :: Layout ) ,
195
+ . in_set ( UiSystem :: PostLayout ) ,
175
196
) ,
176
197
) ;
177
198
@@ -203,7 +224,7 @@ fn build_text_interop(app: &mut App) {
203
224
PostUpdate ,
204
225
(
205
226
widget:: measure_text_system
206
- . before ( UiSystem :: Layout )
227
+ . in_set ( UiSystem :: Prepare )
207
228
// Potential conflict: `Assets<Image>`
208
229
// In practice, they run independently since `bevy_render::camera_update_system`
209
230
// will only ever observe its own render target, and `widget::measure_text_system`
@@ -217,7 +238,7 @@ fn build_text_interop(app: &mut App) {
217
238
// FIXME: Add an archetype invariant for this https://github.com/bevyengine/bevy/issues/1481.
218
239
. ambiguous_with ( widget:: update_image_content_size_system) ,
219
240
widget:: text_system
220
- . after ( UiSystem :: Layout )
241
+ . in_set ( UiSystem :: PostLayout )
221
242
. after ( bevy_text:: remove_dropped_font_atlas_sets)
222
243
// Text2d and bevy_ui text are entirely on separate entities
223
244
. ambiguous_with ( bevy_text:: update_text2d_layout) ,
0 commit comments