Bevy AssetIO Plugin For Reading Optionally Obfuscated Zips #1398
zicklag
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey everybody! I just released a Bevy plugin that allows you to bundle your assets for your game in an optionally obfuscated zip file:
bevy_assetio_zip
.The obfuscated zip option will scramble the bits of the asset zip by XOR-ing the bytes to make it unrecognizable without XOR-ing it again. It is no real protection, but it does prevent the casual user from being able to recognize the asset format. The plugin by default will read assets from either an
assets.zip
or anassets.bin
file and will fall back to the default bevy asset loader if it can't find an asset in the bundle.Usage
Simply enable the plugin when setting up your Bevy app to enable loading from asset bundle
files.
Once enabling the plugin, the game will now search for
assets.zip
andassets.bin
filesadjacent to the executable when attempting to load assets. If an asset is not found in the zip
file, it will attempt to load the asset using the default Bevy asset loader for the target
platform.
Types of Asset Bundles
There are two kinds of asset bundle files supported by this plugin, plain
.zip
files andobfuscated zip files ( which have a
.bin
extension ). Plain.zip
files are typical zip filesthat can be created with normal zip software. Obfuscated zip files can be created with
[
bevy_assetio_zip_bundler
] and are simply a normal zip file that has had the bytes XOR-ed by0b01010101
.Bundling Assets
To bundle your bevy assets you can use the [
bevy_assetio_zip_bundler
] crate. The easiest wayto use it is to add this to your
build.rs
file:This will automatically zip up your crate's
assets
folder and put it in yourtarget/
dirwhen compiling release builds. When distributing your application simply take your asset bundle
and place it adjacent to the executable and Bevy will attempt to load assets from the bundle
before falling back to the
assets
dir.You can configure the name, obfuscation, and compression of the bundle by creating and
asset_config.toml
file next to yourCargo.toml
file:Alternatively, if you want to create your own tooling or customize the asset bundling process,
you can manually bundle the assets using the
bevy_assetio_zip_bundler::bundle_assets
function.
Beta Was this translation helpful? Give feedback.
All reactions