Bundled assets for Bevy

Features

Status

Works for the Bevy 0.3.0. See Bevy issue 606 and the linked PRs for discussion of native Bevy support for bundling assets.

Installation

shell cargo add bevy_prototype_inline_assets

or, in your Cargo.toml:

toml bevy_prototype_inline_assets = "0.1.0"

Usage

``` rust use bevy::asset::{AssetPlugin, LoadState}; use bevy::prelude::*; use bevyprototypeinlineassets::{inlineassets, InlineAssets, InlineAssetsPlugin}; use std::collections::HashMap; use std::path::Path;

fn main() { let inlineassets = inlineassets![ "assets/image.png", "assets/font.ttf", "assets/audio.mp3", ... ]; App::build() .addresource(inlineassets) .addpluginswith(DefaultPlugins, |group| { group.addafter::(InlineAssetsPlugin) }) .initresource::>() .addstartupsystem(setup.system()) .add_system(spawn.system()) .run(); }

fn setup( mut commands: Commands, inlineassets: Res, assetserver: Res, mut inlineassethandles: ResMut>, ) { *inlineassethandles = inlineassets.loadall(asset_server); }

fn spawn( mut commands: Commands, inlineassethandles: Res>, assetserver: Res, loaded: Local, ) { if *loaded || assetserver.getgrouploadstate(inlineassethandles.values().map(|h| h.id)) != LoadState::Loaded { return; } let handle = inlineasset_handles.get(Path::new("assets/image.png")).unwrap().clone().typed(); ... } ```