Skip to content

Commit

Permalink
update for Bevy 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Nov 12, 2023
1 parent 5446e39 commit ba1281b
Show file tree
Hide file tree
Showing 14 changed files with 811 additions and 261 deletions.
13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_embedded_assets"
version = "0.8.0"
version = "0.9.0"
authors = ["François Mockers <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -12,11 +12,20 @@ homepage = "https://github.com/vleue/bevy_embedded_assets"
documentation = "https://docs.rs/bevy_embedded_assets"
categories = ["game-development"]

[features]
default = ["default-source"]
# Support for replacing the default asset source
default-source = ["futures-io", "futures-lite"]

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

[dependencies]
futures-io = { version = "0.3", optional = true }
futures-lite = { version = "2.0", optional = true }

[build-dependencies]
cargo-emit = "0.2.1"

Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ use bevy::prelude::*;
use bevy_embedded_assets::EmbeddedAssetPlugin;

fn main() {
App::new().add_plugins(
DefaultPlugins
.build()
.add_before::<bevy::asset::AssetPlugin, _>(EmbeddedAssetPlugin),
);
App::new().add_plugins((EmbeddedAssetPlugin::default(), DefaultPlugins));
}
```

`EmbeddedAssetPlugin` has three modes:

* `PluginMode::AutoLoad` will embed the asset folder and make it available through the `embedded://` source
* `PluginMode::ReplaceDefault` will embed the asset folder and make it available through the default source
* `PluginMode::ReplaceAndFallback` will embed the asset folder and make it available through the default source. If a fail is not found at runtime, it fallback to the default source for the current platform

## Bevy Compatibility

|Bevy|bevy_embedded_assets|
|---|---|
|main|main|
|0.12|0.9|
|0.11|0.8|
|0.10|0.7|
|0.9|0.6|
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 8 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ fn main() {

let mut file = File::create(dest_path).unwrap();
file.write_all(
"/// Generated function that will add all assets to the [`EmbeddedAssetIo`].
#[allow(unused_variables, clippy::non_ascii_literal)] pub fn include_all_assets(embedded: &mut EmbeddedAssetIo){\n"
"/// Generated function that will embed all assets.
#[allow(unused_variables, unused_qualifications, clippy::non_ascii_literal)]
fn include_all_assets(mut registry: impl EmbeddedRegistry){\n"
.as_ref(),
)
.unwrap();
Expand All @@ -76,12 +77,12 @@ fn main() {
let mut path = path.to_string_lossy().to_string();
if building_for_wasm {
// building for wasm. replace paths with forward slash in case we're building from windows
path = path.replace('\\', "/");
path = path.replace(std::path::MAIN_SEPARATOR, "/");
}
cargo_emit::rerun_if_changed!(fullpath.to_string_lossy());
file.write_all(
format!(
r#"embedded.add_asset(std::path::Path::new({:?}), include_bytes!({:?}));
r#" registry.insert_included_asset({:?}, include_bytes!({:?}));
"#,
path,
fullpath.to_string_lossy()
Expand All @@ -98,8 +99,9 @@ fn main() {

let mut file = File::create(dest_path).unwrap();
file.write_all(
"/// Generated function that will add all assets to the [`EmbeddedAssetIo`].
#[allow(unused_variables)] pub fn include_all_assets(embedded: &mut EmbeddedAssetIo){}"
"/// Generated function that will embed all assets.
#[allow(unused_variables, unused_qualifications, clippy::non_ascii_literal)]
fn include_all_assets(registry: impl EmbeddedRegistry){}"
.as_ref(),
)
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions runtime_assets/asset.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
at runtime
Loading

0 comments on commit ba1281b

Please sign in to comment.