diff --git a/crates/bevy_ecs/src/storage/resource.rs b/crates/bevy_ecs/src/storage/resource.rs index edfa51e128..e047fb3c96 100644 --- a/crates/bevy_ecs/src/storage/resource.rs +++ b/crates/bevy_ecs/src/storage/resource.rs @@ -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 { + self.resources.iter().map(|(id, data)| (*id, data)) + } + /// Returns true if there are no resources stored in the [`World`], /// false otherwise. ///