Bevy Assets Bundler

github action codecov dependency status loc License

crates.io docs.rs

Assets Bundler for bevy, with content encryption support. Current archive format is tar and encryption algorithm is AES

Features

Installation

```toml

Cargo.toml

[dependencies] bevy = "0.8" bevyassetsbundler = "0.4"

[build-dependencies] bevyassetsbundler = "0.4" ```

Build Script

You can generate a random key with this playground

```rust use bevyassetsbundler::*;

// build.rs // encryption key: [u8; 16] array // make sure the key is consistent between build.rs and main.rs // or follow the example code to share code between build.rs and main.rs fn main() { let key = [30, 168, 132, 180, 250, 203, 124, 96, 221, 206, 64, 239, 102, 20, 139, 79]; let mut options = AssetBundlingOptions::default(); options.setencryptionkey(key); options.encodefilenames = true; options.enabledondebug_build = true; AssetBundler::from(options).build();//.unwrap(); } ```

Bevy Setup

```rust use bevyassetsbundler::; use bevy::{asset::AssetPlugin, prelude::};

fn main() { // encryption key: [u8; 16] array // make sure the key is consistent between build.rs and main.rs // or follow the example code to share code between build.rs and main.rs let key = [30, 168, 132, 180, 250, 203, 124, 96, 221, 206, 64, 239, 102, 20, 139, 79]; let mut options = AssetBundlingOptions::default(); options.setencryptionkey(key); options.encodefilenames = true; options.enabledondebug_build = true;

App::new()
    .add_plugins_with(DefaultPlugins, |group| {
        group.add_before::<AssetPlugin, _>(BundledAssetIoPlugin::from(
            options.clone(),
        ))
    })
    .add_startup_system(setup)
    .run();

}

fn setup(mut commands: Commands, asset_server: Res) { } ```

Options

```rust

[derive(Debug, Clone)]

pub struct AssetBundlingOptions { #[cfg(feature = "encryption")] pub encryptionon: bool, #[cfg(feature = "encryption")] pub encryptionkey: Option<[u8; 16]>, #[cfg(feature = "compression")] pub enablecompression: bool, pub enabledondebugbuild: bool, pub encodefilenames: bool, pub assetbundlename: String, } ```

TODO

Bevy Version Supported

|bevy|bevyassetsbundler| |---|---| |main|bevy_main| |0.8|0.4| |0.7|0.3| |0.6|0.2| |0.5|0.1|

Examples

Check out example and E2E test

To run example: cargo run -p example

go to target/release folder, now you can move example(.exe) and assets.bin to some other place and run, just keep the relative path between them.

Disclaimer

The encryption mechnism this library provides does not protect your assets from ALL kinds of reverse engineering as long as the game executable and the assets bundle are distributed to end users.

License

MIT