@@ -4,6 +4,7 @@ use crate::{
44 UiState ,
55 core:: EguiWindow ,
66 editor_windows:: saving:: { SaveWindow , SaveWindowAssetMeta } ,
7+ global_state:: { ClearGlobalState , active_fsm:: ActiveFsm , active_graph:: ActiveGraph } ,
78 } ,
89} ;
910use bevy:: { asset:: UntypedAssetId , platform:: collections:: HashMap , prelude:: * } ;
@@ -96,9 +97,9 @@ pub fn handle_save_graph(
9697 In ( save_graph) : In < SaveGraph > ,
9798 asset_server : Res < AssetServer > ,
9899 graph_assets : Res < Assets < AnimationGraph > > ,
99- mut ui_state : ResMut < UiState > ,
100100 cli : Res < Cli > ,
101101 registry : Res < AppTypeRegistry > ,
102+ mut commands : Commands ,
102103) {
103104 let type_registry = registry. 0 . read ( ) ;
104105 let graph = graph_assets. get ( save_graph. asset_id ) . unwrap ( ) ;
@@ -121,16 +122,16 @@ pub fn handle_save_graph(
121122 // editor selection.
122123 // Also delete the temporary asset
123124 if asset_server. get_path ( save_graph. asset_id ) . is_none ( ) {
124- ui_state . global_state . graph_editor = None ;
125+ commands . trigger ( ClearGlobalState :: < ActiveGraph > :: default ( ) ) ;
125126 }
126127}
127128
128129pub fn handle_save_fsm (
129130 In ( save_fsm) : In < SaveFsm > ,
130131 asset_server : Res < AssetServer > ,
131132 graph_assets : Res < Assets < StateMachine > > ,
132- mut ui_state : ResMut < UiState > ,
133133 cli : Res < Cli > ,
134+ mut commands : Commands ,
134135) {
135136 let fsm = graph_assets. get ( save_fsm. asset_id ) . unwrap ( ) ;
136137 let graph_serial = StateMachineSerial :: from ( fsm) ;
@@ -152,15 +153,13 @@ pub fn handle_save_fsm(
152153 // editor selection.
153154 // Also delete the temporary asset
154155 if asset_server. get_path ( save_fsm. asset_id ) . is_none ( ) {
155- ui_state . global_state . fsm_editor = None ;
156+ commands . trigger ( ClearGlobalState :: < ActiveFsm > :: default ( ) ) ;
156157 }
157158}
158159
159160pub fn handle_save_animation_clip (
160161 In ( save_fsm) : In < SaveClip > ,
161- asset_server : Res < AssetServer > ,
162162 clip_assets : Res < Assets < GraphClip > > ,
163- mut ui_state : ResMut < UiState > ,
164163 cli : Res < Cli > ,
165164) {
166165 let clip = clip_assets. get ( save_fsm. asset_id ) . unwrap ( ) ;
@@ -181,13 +180,6 @@ pub fn handle_save_animation_clip(
181180 ron:: ser:: PrettyConfig :: default ( ) ,
182181 )
183182 . unwrap ( ) ;
184-
185- // If we just saved a newly created graph, unload the in-memory asset from the
186- // editor selection.
187- // Also delete the temporary asset
188- if asset_server. get_path ( save_fsm. asset_id ) . is_none ( ) {
189- ui_state. global_state . fsm_editor = None ;
190- }
191183}
192184
193185pub fn handle_save_colliders (
0 commit comments