
# 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 https://github.com/bevyengine/bevy/pull/17121 by allowing `bevy_winit` to depend on `bevy_image` instead of `bevy_sprite` which is a [non-starter]. [non-starter]: https://github.com/bevyengine/bevy/pull/17121#discussion_r1904955083 ## 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.
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
|
|
#![allow(unsafe_code)]
|
|
|
|
extern crate alloc;
|
|
|
|
pub mod prelude {
|
|
pub use crate::{
|
|
dynamic_texture_atlas_builder::DynamicTextureAtlasBuilder,
|
|
texture_atlas::{TextureAtlas, TextureAtlasLayout, TextureAtlasSources},
|
|
BevyDefault as _, Image, ImageFormat, TextureAtlasBuilder, TextureError,
|
|
};
|
|
}
|
|
|
|
mod image;
|
|
pub use self::image::*;
|
|
#[cfg(feature = "basis-universal")]
|
|
mod basis;
|
|
#[cfg(feature = "basis-universal")]
|
|
mod compressed_image_saver;
|
|
#[cfg(feature = "dds")]
|
|
mod dds;
|
|
mod dynamic_texture_atlas_builder;
|
|
#[cfg(feature = "exr")]
|
|
mod exr_texture_loader;
|
|
#[cfg(feature = "hdr")]
|
|
mod hdr_texture_loader;
|
|
mod image_loader;
|
|
#[cfg(feature = "ktx2")]
|
|
mod ktx2;
|
|
mod texture_atlas;
|
|
mod texture_atlas_builder;
|
|
|
|
#[cfg(feature = "basis-universal")]
|
|
pub use compressed_image_saver::*;
|
|
#[cfg(feature = "dds")]
|
|
pub use dds::*;
|
|
pub use dynamic_texture_atlas_builder::*;
|
|
#[cfg(feature = "exr")]
|
|
pub use exr_texture_loader::*;
|
|
#[cfg(feature = "hdr")]
|
|
pub use hdr_texture_loader::*;
|
|
pub use image_loader::*;
|
|
#[cfg(feature = "ktx2")]
|
|
pub use ktx2::*;
|
|
pub use texture_atlas::*;
|
|
pub use texture_atlas_builder::*;
|
|
|
|
pub(crate) mod image_texture_conversion;
|
|
pub use image_texture_conversion::IntoDynamicImageError;
|