8 releases (breaking)

0.9.0 Aug 2, 2024
0.8.0 Feb 22, 2024
0.7.0 Nov 20, 2023
0.5.0 Nov 13, 2022
0.1.0 Sep 18, 2021

#1144 in Network programming

Download history 127/week @ 2024-07-30 28/week @ 2024-08-06 7/week @ 2024-08-13 13/week @ 2024-08-27 20/week @ 2024-09-03 4/week @ 2024-09-10 12/week @ 2024-09-17 48/week @ 2024-09-24 28/week @ 2024-10-01 23/week @ 2024-10-08 21/week @ 2024-10-15 3/week @ 2024-10-22 17/week @ 2024-10-29 18/week @ 2024-11-05

71 downloads per month

MIT/Apache

86KB
222 lines

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.

bevy bevy_web_asset
0.14 0.9, main
0.13 0.8
0.12 0.7
0.9 0.5
0.8 0.4
0.7 0.3
0.6 0.2
0.5 0.1

License

bevy_web_asset is dual-licensed under either

at your option.

Contributions

PRs welcome!

Dependencies

~23–66MB
~1M SLoC