How can exchange the texture of a SpriteBundle at runtime? #8054
-
I want to be able to change the texture used by a sprite bundle from within a system at runtime. I tried searching trough existing Q&A threads, but all I could find was #2892 which uses Any tips would be appreciated, thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The answer of #2892 also applies here. You can change the value of the fn update_sprite(asset_server: Res<AssetServer>, query: Query<&mut Handle<Image>, With<MyMarkerComponent>>) {
let mut handle = query.single_mut();
*handle = asset_server.load("sprites/new_sprite.png");
} |
Beta Was this translation helpful? Give feedback.
The answer of #2892 also applies here. You can change the value of the
Handle<Image>
component.Slightly adjusted code example from #2892: