#Sometimes image is not displayed

10 messages · Page 1 of 1 (latest)

dim scarab
#

I'm rendering player image using SpriteSheetBundle and I'm having this strange issue that sometimes image is not being displayed. I mean - run game and it is displayed. Rerun and it is not. Rerun few times and is again displayed.

#

worth noting that when image is not displayed, I can see in bevy_editor_pls that Handle<TextureAtlas> is empty

#

I'm loading all image on one state and displaying player on another, can it be that handle somehow expired between this states?

#

spritesheet loading and texture creating done in this way

#[derive(Default)]
pub struct TextureAtlases{
  pub player: Handle<TextureAtlas>,
}
...
mut texture_handles: ResMut<TextureAtlases>,
...
  loading.0.append(&mut asset_server.load_folder("images").unwrap().clone());
  
  texture_handles.player = textures.add(TextureAtlas::from_grid(
    asset_server.get_handle("images/players.png"),
    Vec2::new(32.,32.),
    11, 
    11
  ));

than in other state, I'm using texture handle stored in resource

brisk stirrup
#

My understanding is that loading of resources is not tied to stages. It's totally asynchronous. It becomes available when it's ready

dim scarab
#

so the problem is that I should wait for assets are actually continue loading?

brisk stirrup
#

It depends. You can wait until your asset is loaded if you wish, by using asset events. Or you can use an asset handle normally even if it refers to an asset that hasn't been loaded yet, and it will sort of pop into existence when it's loaded

dim scarab
#

it will sort of pop into existence when it's loaded in my case if it not shown-up then it will not never in future. Unless I restart app