Skip to content

Commit

Permalink
assets.get can take any kind of handle
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Dec 14, 2022
1 parent b7d6ee8 commit 5d93974
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl<T: Asset> Assets<T> {
///
/// This is the main method for accessing asset data from an [Assets] collection. If you need
/// mutable access to the asset, use [`get_mut`](Assets::get_mut).
pub fn get(&self, handle: &Handle<T>) -> Option<&T> {
pub fn get<H: Into<HandleId>>(&self, handle: H) -> Option<&T> {
self.assets.get(&handle.into())
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<A: Asset + FromReflect> FromType<A> for ReflectAsset {
assets_resource_type_id: TypeId::of::<Assets<A>>(),
get: |world, handle| {
let assets = world.resource::<Assets<A>>();
let asset = assets.get(&handle.typed());
let asset = assets.get(handle);
asset.map(|asset| asset as &dyn Reflect)
},
get_mut: |world, handle| {
Expand Down

0 comments on commit 5d93974

Please sign in to comment.