Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when using image annotation on Handle<Image> field #229

Closed
Gingeh opened this issue Jul 11, 2024 · 2 comments · Fixed by #231
Closed

Panic when using image annotation on Handle<Image> field #229

Gingeh opened this issue Jul 11, 2024 · 2 comments · Fixed by #231

Comments

@Gingeh
Copy link

Gingeh commented Jul 11, 2024

Using the #[asset(image(...))] on an image field causes the app to panic with "Only asset collection fields holding an Image handle can be annotated with image".

Here is an example which panics when run (with the necessary asset):

use bevy::prelude::*;
use bevy_asset_loader::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .init_collection::<MyAssets>()
        .run();
}

#[derive(AssetCollection, Resource)]
struct MyAssets {
    #[asset(path = "my_image.png")]
    #[asset(image(sampler = nearest))]
    my_image: Handle<Image>,
}
@NiklasEi
Copy link
Owner

This is expected and I will edit the documentation to mention that the image annotation requires using a loading state.

The problem is that to change things like the sampler, I need to take the asset from the asset collection. For that, it needs to be loaded. But without a loading state, I cannot run code at the point where the asset is loaded.

@NiklasEi
Copy link
Owner

I opened #230 to look into supporting the image annotation without a loading state, but I consider this issue closed with the updated documentation in #231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants