I load resource like this
#[img_handle_resource(path = "test.png")]
pub struct ShipPlaceholder;
pub fn load_all_sprites(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.insert_resource(ShipPlaceholder { img: asset_server.load(ShipPlaceholder::asset_path())} );
}
Then I'm trying to use like this
fn load_sprite(mut commands: Commands, texture: Option<Res<ShipPlaceholder>>) {
commands.spawn(SpriteBundle {
texture: texture.expect("no ship placeholder").img.clone(),
sprite: Sprite {
..default()
},
..default()
});
}
and i call these in this way:
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(FramepacePlugin)
.add_startup_system(setup)
.add_startup_system(load_all_sprites)
.add_startup_system(load_sprite)
.add_startup_system(set_fps_limit)
.add_plugin(LogDiagnosticsPlugin::default())
.run();
}
but this one not works with thread 'main' panicked at 'no ship placeholder', which means resource is not delivered, why?