I am fairly new to Bevy and rust. I want to load an png image and get the width and height of it. The code below does not print "found resource ...".
fn setup( mut commands: Commands,
asset_server: Res<AssetServer>,
mut materials: ResMut<Assets<Image>>) {
let texture_handle = asset_server.load("board.png");
//materials.add(texture_handle.clone().into()); //Gives error: the trait `From<Handle<_>>` is not implemented for `bevy::prelude::Image`
commands.spawn().insert_bundle(SpriteBundle {
texture: texture_handle.clone(),
..Default::default()
}).insert(BackgroundSprite);
if let Some(image) = materials.get(texture_handle) {
print!("found resource with width and height: [{},{}]", image.texture_descriptor.size.width, image.texture_descriptor.size.height);
}
}