Crate bevy_web_asset

source ·
Expand description

§Bevy Web Asset

crates.io MIT/Apache 2.0 crates.io docs.rs

This is a tiny crate that that adds the ability to load assets from http and https urls.

Supports both wasm (web-sys) and native.

This is nice if you want to keep your content on a server, even when developing native games. Use cases can be:

  • Tuning game balance post-launch
  • Seasonal events (halloween theme etc.)
  • Downloading dynamic content from 3rd party services (lospec, gltf repositories etc.)
  • Sharing user-created assets/mods over some service (level editor etc.)
  • Keeping initial download size small
  • Testing with different online assets during development

§Usage

NOTE: You need to add the plugin before AssetPlugin:

use bevy::prelude::*;
use bevy_web_asset::WebAssetPlugin;

fn main() {
    App::new()
        // The `WebAssetPlugin` must be inserted before the `AssetPlugin`
        .add_plugins((
            WebAssetPlugin::default(),
            DefaultPlugins
        ))
        // ...
        .run();
}

But using it is quite simple, just use http urls instead of regular asset paths.

let font: Handle<Font> = asset_server.load("https://example.com/fonts/quicksand-light.ttf");

Or:

commands.spawn(SpriteBundle {
    // Simply use a url where you would normally use an asset folder relative path
    texture: asset_server.load("https://johanhelsing.studio/assets/favicon.png"),
    ..default()
});

§Bevy version support

I intend to support the latest bevy release in the main branch.

bevybevy_web_asset
0.130.8, main
0.120.7
0.90.5
0.80.4
0.70.3
0.60.2
0.50.1

§License

bevy_web_asset is dual-licensed under either

  • MIT License (./LICENSE-MIT or http://opensource.org/licenses/MIT)
  • Apache License, Version 2.0 (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)

at your option.

§Contributions

PRs welcome!

Structs§

  • Add this plugin to bevy to support loading http and https urls.

Enums§