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

Support TextureAtlas handles when deriving AssetCollection #7

Closed
NiklasEi opened this issue Aug 7, 2021 · 10 comments · Fixed by #9
Closed

Support TextureAtlas handles when deriving AssetCollection #7

NiklasEi opened this issue Aug 7, 2021 · 10 comments · Fixed by #9

Comments

@NiklasEi
Copy link
Owner

NiklasEi commented Aug 7, 2021

#[derive(AssetCollection)]
struct MyAssets {
    #[asset(texture_atlas(cell_width = 100., cell_height = 96., columns = 8, rows = 1))]
    #[asset(path = "textures/female_adventurer.png")]
    female_adventurer: Handle<TextureAtlas>,
}
@LeonLiuY
Copy link

LeonLiuY commented Sep 5, 2021

Hi, I can run the example atlas_from_grid.rs successfully in this repo. However when I do it in my project I get:

error[E0425]: cannot find value `atlases` in this scope

What could be wrong with my usage?

@NiklasEi
Copy link
Owner Author

NiklasEi commented Sep 5, 2021

You might have turned off the default features?

@LeonLiuY
Copy link

LeonLiuY commented Sep 5, 2021

I don't know you mean which default features.

I'm just using your template https://github.com/NiklasEi/bevy_game_template and change the TextureAssets to use TextureAtlas in loading.rs and it reports that error.

And there is bevy = { version = "0.5.0", default-features = false }, I tried enable default features it still has that error.

If you mean default features of bevy_asset_loader then I think it's enabled.

@NiklasEi
Copy link
Owner Author

NiklasEi commented Sep 5, 2021

Thank you, I can reproduce this issue and will look into it :)

@kirandesimone
Copy link

kirandesimone commented Feb 6, 2022

What was the fix for this issue? I'm currently having the same problem. I'm using v0.8.0

@NiklasEi
Copy link
Owner Author

NiklasEi commented Feb 6, 2022

From version 0.7 on the render feature is no longer a default feature. Did you enable it?

The original issue with the feature was a bug in the derive macro and has been fixed.

@kirandesimone
Copy link

ahh I see ok

This is my cargo.toml file

[features]
render = ["bevy_asset_loader/render"]

[dependencies]
bevy = "0.6.0"
bevy_asset_loader = "0.8.0"

@NiklasEi
Copy link
Owner Author

NiklasEi commented Feb 6, 2022

With that Cargo.toml you will need to activate the render feature of your own crate. Is it working then?

@kirandesimone
Copy link

hmmm not sure I follow, sorry I've never used features before. I just tried to activate it with #[cfg(feature = "render")] but no luck and it inactivates the code??

#[cfg(feature = "render")] #[derive(AssetCollection)] pub struct DungeonTileset { #[asset(texture_atlas(tile_size_x=16., tile_size_y=16., columns=16, rows=16))] #[asset(path="assets/DungeonTileset_v4.png")] sprite_sheet: Handle<TextureAtlas> }

I also tried putting over the mod but no cigar.

@kirandesimone
Copy link

kirandesimone commented Feb 7, 2022

AHHH I GOT IT. ok, thanks a ton for your help!

Just in case someone else stumbles upon this issue:
bevy_asset_loader = { version = "0.8.0", features = ["render"] }

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.

3 participants