Expand description
Bevy plugin offering generic asset loaders for common file formats
This library includes a collection of thin wrapper plugins around serde implementations for the
common file formats json
, ron
, toml
, yaml
, MessagePack
and xml
. Each plugin adds
an asset loader for a user type. Assets of that type will then be loaded from all files with
configurable extensions.
The following example requires the json
feature and loads a custom asset from a json file.
use bevy::prelude::*;
use bevy::reflect::TypePath;
use bevy_common_assets::json::JsonAssetPlugin;
fn main() {
App::new()
.add_plugins((DefaultPlugins, JsonAssetPlugin::<Level>::new(&["level.json"])))
.add_systems(Startup, load_level)
.run();
}
fn load_level(mut commands: Commands, asset_server: Res<AssetServer>) {
let handle = LevelAsset(asset_server.load("trees.level.json"));
commands.insert_resource(handle);
}
#[derive(serde::Deserialize, Asset, TypePath)]
struct Level {
positions: Vec<[f32; 3]>,
}
#[derive(Resource)]
struct LevelAsset(Handle<Level>);
Modulesยง
- csv
csv
Module containing a Bevy plugin to load assets fromcsv
files with custom file extensions. - json
json
Module containing a Bevy plugin to load assets fromjson
files with custom file extensions. - msgpack
msgpack
Module containing a Bevy plugin to load assets fromMessagePack
files with custom file extensions. - postcard
postcard
Module containing a Bevy plugin to load assets frompostcard
files with custom file extensions. - ron
ron
Module containing a Bevy plugin to load assets fromron
files with custom file extensions. - toml
toml
Module containing a Bevy plugin to load assets fromtoml
files with custom file extensions. - xml
xml
Module containing a Bevy plugin to load assets fromxml
files with custom file extensions. - yaml
yaml
Module containing a Bevy plugin to load assets fromyaml
files with custom file extensions.