Skip to content

Commit

Permalink
Merge pull request #17 from vleue/bevy-0.13-update
Browse files Browse the repository at this point in the history
Bevy 0.13 update
  • Loading branch information
mockersf committed Feb 18, 2024
2 parents c5fc4da + cc5900f commit 28ca79e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bevy_embedded_assets"
version = "0.9.1"
version = "0.10.0"
authors = ["François Mockers <mockersf@gmail.com>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -18,7 +18,7 @@ default = ["default-source"]
default-source = ["futures-io", "futures-lite"]

[dependencies.bevy]
version = "0.12"
version = "0.13"
default-features = false
features = ["bevy_asset"]

Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -28,6 +28,7 @@ fn main() {
|Bevy|bevy_embedded_assets|
|---|---|
|main|main|
|0.13|0.10|
|0.12|0.9|
|0.11|0.8|
|0.10|0.7|
Expand Down
13 changes: 7 additions & 6 deletions src/asset_reader.rs
Expand Up @@ -17,22 +17,23 @@ use crate::{include_all_assets, EmbeddedRegistry};
/// Struct which can be used to retrieve embedded assets directly
/// without the normal Bevy `Handle<T>` approach. This is useful
/// for cases where you need an asset outside the Bevy ECS environment.
///
///
/// This is only available when the `default-source` cargo feature is enabled.
///
///
/// Example usage is below which assumes you have an asset named `image.png`
/// in your `assets` folder (which this crate embeds at compile time).
/// ```rust
/// use bevy_embedded_assets::EmbeddedAssetReader;
/// use bevy_embedded_assets::{DataReader, EmbeddedAssetReader};
/// use std::path::Path;
///
///
/// fn some_bevy_system() {
/// let embedded: EmbeddedAssetReader = EmbeddedAssetReader::preloaded();
/// let reader: DataReader = embedded.load_path_sync(&Path::new("image.png")).unwrap();
/// let image_data: Vec<u8> = reader.0.to_vec();
/// // Do what you need with the data
/// }
/// ```
#[allow(clippy::module_name_repetitions)]
pub struct EmbeddedAssetReader {
loaded: HashMap<&'static Path, &'static [u8]>,
fallback: Option<Box<dyn AssetReader>>,
Expand Down Expand Up @@ -68,7 +69,7 @@ impl EmbeddedAssetReader {
}

/// Create an [`EmbeddedAssetReader`] loaded with all the assets found by the build script.
///
///
/// This ensures the [`EmbeddedAssetReader`] has all (embedded) assets loaded and can be used
/// directly without the typical Bevy `Handle<T>` approach. Retrieve assets directly after
/// calling `preloaded` with [`EmbeddedAssetReader::load_path_sync()`].
Expand Down Expand Up @@ -140,7 +141,7 @@ impl EmbeddedAssetReader {

/// A wrapper around the raw bytes of an asset.
/// This is returned by [`EmbeddedAssetReader::load_path_sync()`].
///
///
/// To get the raw data, use `reader.0`.
#[derive(Default, Debug, Clone, Copy)]
pub struct DataReader(pub &'static [u8]);
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Expand Up @@ -27,9 +27,9 @@ use bevy::{
#[cfg(feature = "default-source")]
mod asset_reader;
#[cfg(feature = "default-source")]
pub use asset_reader::EmbeddedAssetReader;
#[cfg(feature = "default-source")]
pub use asset_reader::DataReader;
#[cfg(feature = "default-source")]
pub use asset_reader::EmbeddedAssetReader;

include!(concat!(env!("OUT_DIR"), "/include_all_assets.rs"));

Expand Down

0 comments on commit 28ca79e

Please sign in to comment.