-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Bevy version
0.16.1
What you did
// in any Update schedule
pub fn log_asset_events<A: Asset>(
mut asset_events: EventReader<AssetEvent<A>>,
asset_server: Res<AssetServer>,
) {
for event in asset_events.read() {
if let AssetEvent::Added { id } = event {
let path = asset_server.get_path(*id);
trace!("Loading asset {id} at `{path:?}`");
} else if let AssetEvent::Unused { id } = event {
let path = asset_server.get_path(*id);
debug!("Unused asset {id} at path `{path:?}`");
}
}
}
What went wrong
on ::Unused event, the AssetServer::get_path method returns None for asset id that had a path on ::Loading event
Additional information
i guess its because the assets information have already been removed, but maybe its possible to keep them a little while longer; just the path one more frame to allows systems to easily access the path for logging for example ?
i marked as bug because in a really naive approach, between Unused and Removed events the assets could still be here, but in practice when we read the event its already too late
the users can just store the path in a Local otherwise, but having get_path working would still be useful as a QoL improvement, so users dont have to find that it doesn't work, then wonder why and implement a solution themselves.
if this is not useful or worth it, feel free to close this !!