Skip to content

Commit

Permalink
Wait for dependencies to load
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasEi committed Jul 12, 2024
1 parent 958f971 commit c08107d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions bevy_asset_loader/src/loading_state/systems.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::asset::{AssetServer, LoadState};
use bevy::asset::{AssetServer, DependencyLoadState, LoadState, RecursiveDependencyLoadState};
use bevy::ecs::system::SystemState;
use bevy::ecs::world::{FromWorld, World};
use bevy::log::{debug, info, trace, warn};
Expand Down Expand Up @@ -107,15 +107,14 @@ fn count_loaded_handles<S: FreelyMutableState, Assets: AssetCollection>(

let failure = loading_asset_handles.handles.iter().any(|handle| {
matches!(
asset_server.get_load_state(handle.id()),
Some(LoadState::Failed(_))
asset_server.get_recursive_dependency_load_state(handle.id()),
Some(RecursiveDependencyLoadState::Failed)
)
});
let done = loading_asset_handles
.handles
.iter()
.map(|handle| asset_server.get_load_state(handle.id()))
.filter(|state| state == &Some(LoadState::Loaded))
.filter(|handle| asset_server.is_loaded_with_dependencies(handle.id()))
.count();
if done < total && !failure {
return (done as u32, total as u32);
Expand Down

0 comments on commit c08107d

Please sign in to comment.