-
Hi, new to bevy, and I'm trying to understand why my asset is being dropped. I created a minimal example to highlight the problem I'm running into. It's basically the bevy Sprite example, except I'm using an image asset created in code. I'm Code:
Output:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
When it comes to manually adding assets like this, as soon as the scope of that system ends, the strong handle is dropped. If no strong handles exist, the asset is removed. You can store the handle in a resource or a local and that would prevent the drop! |
Beta Was this translation helpful? Give feedback.
-
OK I think some debugging showed me the issue. In this case the asset wasn't being removed due to the handle's reference count going to zero, but because the image was being extracted into the Render World. bevy/crates/bevy_render/src/render_asset.rs Line 246 in a2fc9de I tried changing the asset usage from |
Beta Was this translation helpful? Give feedback.
OK I think some debugging showed me the issue. In this case the asset wasn't being removed due to the handle's reference count going to zero, but because the image was being extracted into the Render World.
bevy/crates/bevy_render/src/render_asset.rs
Line 246 in a2fc9de
I tried changing the asset usage from
RenderAssetUsages::RENDER_WORLD
toRenderAssetUsages::RENDER_WORLD | RenderAssetUsages::MAIN_WORLD
and now it's not dropped! Thanks for the help!