bevy/release-content/migration-guides/reflect_asset_asset_ids.md
andriyDev 98c14e5917
Replace UntypedHandle from ReflectAsset with impl Into<UntypedAssetId>. (#19606)
# Objective

- A step towards #19024.
- Allow `ReflectAsset` to work with any `AssetId` not just `Handle`.
- `ReflectAsset::ids()` returns an iterator of `AssetId`s, but then
there's no way to use these ids, since all the other APIs in
`ReflectAsset` require a handle (and we don't have a reflect way to get
the handle).

## Solution

- Replace the `UntypedHandle` argument in `ReflectAsset` methods with
`impl Into<UntypedAssetId>`.
- This matches the regular asset API.
- This allows `ReflectAsset::ids()` to be more useful.

## Testing

- None.
2025-06-15 16:42:54 +00:00

801 B

title: ReflectAsset now uses UntypedAssetId instead of UntypedHandle. pull_requests: [19606]

Previously, ReflectAsset methods all required having UntypedHandle. The only way to get an UntypedHandle through this API was with ReflectAsset::add. ReflectAsset::ids was not very useful in this regard.

Now, all methods have been changed to accept impl Into<UntypedAssetId>, which matches our regular Assets<T> API. This means you may need to change how you are calling these methods.

For example, if your code previously looked like:

let my_handle: UntypedHandle;
let my_asset = reflect_asset.get_mut(world, my_handle).unwrap();

You can migrate it to:

let my_handle: UntypedHandle;
let my_asset = reflect_asset.get_mut(world, &my_handle).unwrap();