@@ -69,13 +69,15 @@ impl EditorWindow for GizmoWindow {
69
69
entities : Query < Entity , ( With < EntityShouldShowGizmo > , Without < GizmoTarget > ) > ,
70
70
) {
71
71
for entity in entities. iter ( ) {
72
+ if let Some ( mut entity) = commands. get_entity ( entity) {
72
73
trace ! (
73
74
"Hydrating a gizmo on entity {:?} because it is selected" ,
74
- entity
75
+ entity. id ( )
75
76
) ;
76
- // implicitly assumes it is the only gizmo system in the world,
77
+ // implicitly assumes it is the only gizmo target in the world,
77
78
// otherwise setting [GizmoTarget].is_focussed may be necessary
78
- commands. entity ( entity) . insert ( GizmoTarget :: default ( ) ) ;
79
+ entity. insert ( GizmoTarget :: default ( ) ) ;
80
+ }
79
81
}
80
82
}
81
83
@@ -85,11 +87,13 @@ impl EditorWindow for GizmoWindow {
85
87
entities : Query < Entity , ( With < GizmoTarget > , Without < EntityShouldShowGizmo > ) > ,
86
88
) {
87
89
for entity in entities. iter ( ) {
88
- commands. entity ( entity) . remove :: < GizmoTarget > ( ) ;
89
- debug ! (
90
- "Removing GizmoTarget from entity {:?} because it has lost focus" ,
91
- entity
92
- ) ;
90
+ if let Some ( mut entity) = commands. get_entity ( entity) {
91
+ entity. remove :: < GizmoTarget > ( ) ;
92
+ debug ! (
93
+ "Removing GizmoTarget from entity {:?} because it has lost focus" ,
94
+ entity. id( )
95
+ ) ;
96
+ }
93
97
}
94
98
}
95
99
@@ -101,7 +105,9 @@ impl EditorWindow for GizmoWindow {
101
105
102
106
let selected_entities = hierarchy_state. selected . iter ( ) ;
103
107
for entity in selected_entities {
104
- world. entity_mut ( entity) . insert ( EntityShouldShowGizmo ) ;
108
+ if let Some ( mut entity) = world. get_entity_mut ( entity) {
109
+ entity. insert ( EntityShouldShowGizmo ) ;
110
+ }
105
111
}
106
112
107
113
world. run_system_once ( hydrate_gizmos) ;
@@ -230,4 +236,4 @@ fn add_gizmo_markers(
230
236
) ) ;
231
237
} ) ;
232
238
}
233
- }
239
+ }
0 commit comments