Skip to content

Commit

Permalink
Merge pull request #204 from NiklasEi/failure_state_for_dynamic_asset…
Browse files Browse the repository at this point in the history
…_collections

Move to configured failure state when dynamic asset file fails loading
  • Loading branch information
NiklasEi authored Feb 29, 2024
2 parents 12e0b98 + 4d85aab commit c0a0fa0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions bevy_asset_loader/src/loading_state/dynamic_asset_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ pub(crate) fn check_dynamic_asset_collections<S: States, C: DynamicAssetCollecti
if loading_collections.is_none() {
return;
}
let config = asset_loader_config
.state_configurations
.get_mut(state.get())
.expect("No asset loader configuration for current state");
let loading_collections = loading_collections.as_mut().unwrap();
for handle in &loading_collections.handles {
if let Some(load_state) = asset_server.get_load_state(handle.id()) {
if load_state == LoadState::Failed {
config.loading_failed = true;
continue;
}
if load_state != LoadState::Loaded {
return;
}
Expand All @@ -76,15 +84,10 @@ pub(crate) fn check_dynamic_asset_collections<S: States, C: DynamicAssetCollecti
}
}
for collection in loading_collections.handles.drain(..) {
let collection = dynamic_asset_collections
.get(collection.typed::<C>())
.unwrap();
collection.register(&mut asset_keys);
if let Some(collection) = dynamic_asset_collections.get(collection.typed::<C>()) {
collection.register(&mut asset_keys);
}
}
let config = asset_loader_config
.state_configurations
.get_mut(state.get())
.expect("No asset loader configuration for current state");
config
.loading_dynamic_collections
.remove(&TypeId::of::<C>());
Expand Down

0 comments on commit c0a0fa0

Please sign in to comment.