@@ -102,10 +102,15 @@ impl UiSurface {
102
102
}
103
103
}
104
104
105
- /// Update the `MeasureFunc` of the taffy node corresponding to the given [`Entity`].
106
- pub fn update_measure ( & mut self , entity : Entity , measure_func : taffy:: node:: MeasureFunc ) {
107
- let taffy_node = self . entity_to_taffy . get ( & entity) . unwrap ( ) ;
108
- self . taffy . set_measure ( * taffy_node, Some ( measure_func) ) . ok ( ) ;
105
+ /// Update the `MeasureFunc` of the taffy node corresponding to the given [`Entity`] if the node exists.
106
+ pub fn try_update_measure (
107
+ & mut self ,
108
+ entity : Entity ,
109
+ measure_func : taffy:: node:: MeasureFunc ,
110
+ ) -> Option < ( ) > {
111
+ let taffy_node = self . entity_to_taffy . get ( & entity) ?;
112
+
113
+ self . taffy . set_measure ( * taffy_node, Some ( measure_func) ) . ok ( )
109
114
}
110
115
111
116
/// Update the children of the taffy node corresponding to the given [`Entity`].
@@ -305,7 +310,7 @@ pub fn ui_layout_system(
305
310
Some ( camera_entity) => {
306
311
let Ok ( ( _, camera) ) = cameras. get ( camera_entity) else {
307
312
warn ! (
308
- "TargetCamera is pointing to a camera {:?} which doesn't exist" ,
313
+ "TargetCamera (of root UI node {entity:?}) is pointing to a camera {:?} which doesn't exist" ,
309
314
camera_entity
310
315
) ;
311
316
continue ;
@@ -356,7 +361,7 @@ pub fn ui_layout_system(
356
361
}
357
362
for ( entity, mut content_size) in & mut measure_query {
358
363
if let Some ( measure_func) = content_size. measure_func . take ( ) {
359
- ui_surface. update_measure ( entity, measure_func) ;
364
+ ui_surface. try_update_measure ( entity, measure_func) ;
360
365
}
361
366
}
362
367
0 commit comments