Skip to content

Move TextureAtlas and friends into bevy_image #17219

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

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

mgi388
Copy link
Contributor

@mgi388 mgi388 commented Jan 7, 2025

Objective

Solution

  • Move TextureAtlas, TextureAtlasBuilder, TextureAtlasSources, TextureAtlasLayout and DynamicTextureAtlasBuilder into bevy_image.
  • Add a new plugin to bevy_image named TextureAtlasPlugin which allows us to register TextureAtlas and TextureAtlasLayout which was previously done in SpritePlugin. Since SpritePlugin did the registration previously, we just need to make it add TextureAtlasPlugin.

Testing

  • CI builds it.
  • I also ran multiple examples which hopefully covered any issues:
$ cargo run --example sprite
$ cargo run --example text
$ cargo run --example ui_texture_atlas
$ cargo run --example sprite_animation
$ cargo run --example sprite_sheet
$ cargo run --example sprite_picking

Migration Guide

The following types have been moved from bevy_sprite to bevy_image: TextureAtlas, TextureAtlasBuilder, TextureAtlasSources, TextureAtlasLayout and DynamicTextureAtlasBuilder.

If you are using the bevy crate, and were importing these types directly (e.g. before use bevy::sprite::TextureAtlas), be sure to update your import paths (e.g. after use bevy::image::TextureAtlas)

If you are using the bevy prelude to import these types (e.g. use bevy::prelude::*), you don't need to change anything.

If you are using the bevy_sprite subcrate, be sure to add bevy_image as a dependency if you do not already have it, and be sure to update your import paths.

@IQuick143 IQuick143 added A-Rendering Drawing game state to the screen M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 7, 2025
@mgi388 mgi388 requested a review from kristoff3r January 7, 2025 10:51
Copy link
Contributor

@ickshonpe ickshonpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to remove the bevy_sprite dependency from bevy_ui completely as well, this seems like a good first step.

Don't see any problems with these changes, all the examples still work fine.

@BenjaminBrienen BenjaminBrienen added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 7, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 7, 2025
Merged via the queue into bevyengine:main with commit e24ae6c Jan 7, 2025
33 checks passed
@mgi388 mgi388 deleted the mv-texture-atlas branch January 7, 2025 22:20
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 4, 2025
# Objective

- Allow other crates to use `TextureAtlas` and friends without needing
to depend on `bevy_sprite`.
- Specifically, this allows adding `TextureAtlas` support to custom
cursors in bevyengine#17121 by allowing
`bevy_winit` to depend on `bevy_image` instead of `bevy_sprite` which is
a [non-starter].

[non-starter]:
bevyengine#17121 (comment)

## Solution

- Move `TextureAtlas`, `TextureAtlasBuilder`, `TextureAtlasSources`,
`TextureAtlasLayout` and `DynamicTextureAtlasBuilder` into `bevy_image`.
- Add a new plugin to `bevy_image` named `TextureAtlasPlugin` which
allows us to register `TextureAtlas` and `TextureAtlasLayout` which was
previously done in `SpritePlugin`. Since `SpritePlugin` did the
registration previously, we just need to make it add
`TextureAtlasPlugin`.

## Testing

- CI builds it.
- I also ran multiple examples which hopefully covered any issues:

```
$ cargo run --example sprite
$ cargo run --example text
$ cargo run --example ui_texture_atlas
$ cargo run --example sprite_animation
$ cargo run --example sprite_sheet
$ cargo run --example sprite_picking
```

---

## Migration Guide

The following types have been moved from `bevy_sprite` to `bevy_image`:
`TextureAtlas`, `TextureAtlasBuilder`, `TextureAtlasSources`,
`TextureAtlasLayout` and `DynamicTextureAtlasBuilder`.

If you are using the `bevy` crate, and were importing these types
directly (e.g. before `use bevy::sprite::TextureAtlas`), be sure to
update your import paths (e.g. after `use bevy::image::TextureAtlas`)

If you are using the `bevy` prelude to import these types (e.g. `use
bevy::prelude::*`), you don't need to change anything.

If you are using the `bevy_sprite` subcrate, be sure to add `bevy_image`
as a dependency if you do not already have it, and be sure to update
your import paths.
github-merge-queue bot pushed a commit that referenced this pull request Mar 18, 2025
# Objective

- #17219 introduced a circular dependency between bevy_image and
bevy_sprite for documentation

## Solution

- Remove the circular dependency
- Simplify the doc example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants