mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
add Resources::iter
to iterate over all resource IDs (#6592)
# Objective In bevy 0.8 you could list all resources using `world.archetypes().resource().components()`. As far as I can tell the resource archetype has been replaced with the `Resources` storage, and it would be nice if it could be used to iterate over all resource component IDs as well. ## Solution - add `fn Resources::iter(&self) -> impl Iterator<Item = (ComponentId, &ResourceData)>`
This commit is contained in:
parent
69011b7e26
commit
b2090e3a8d
1 changed files with 5 additions and 0 deletions
|
@ -137,6 +137,11 @@ impl Resources {
|
|||
self.resources.len()
|
||||
}
|
||||
|
||||
/// Iterate over all resources that have been initialized, i.e. given a [`ComponentId`]
|
||||
pub fn iter(&self) -> impl Iterator<Item = (ComponentId, &ResourceData)> {
|
||||
self.resources.iter().map(|(id, data)| (*id, data))
|
||||
}
|
||||
|
||||
/// Returns true if there are no resources stored in the [`World`],
|
||||
/// false otherwise.
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue