Assets path are already removed on AssetEvents::Unused
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
0.16.1
## What you did
```rust
// in any Update schedule
pub fn log_asset_events(
mut asset_events: EventReader>,
asset_server: Res,
) {
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 !!
Contributor guide
Assessment
This issue has not been assessed yet.