Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/examples/asset/web_asset.rs
6592 views
1
//! Example usage of the `https` asset source to load assets from the web.
2
//!
3
//! Run with the feature `https`, and optionally `web_asset_cache`
4
//! for a simple caching mechanism that never invalidates.
5
//!
6
use bevy::{asset::io::web::WebAssetPlugin, prelude::*};
7
8
fn main() {
9
App::new()
10
.add_plugins(DefaultPlugins.set(WebAssetPlugin {
11
silence_startup_warning: true,
12
}))
13
.add_systems(Startup, setup)
14
.run();
15
}
16
17
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
18
commands.spawn(Camera2d);
19
let url = "https://raw.githubusercontent.com/bevyengine/bevy/refs/heads/main/assets/branding/bevy_bird_dark.png";
20
// Simply use a url where you would normally use an asset folder relative path
21
commands.spawn(Sprite::from_image(asset_server.load(url)));
22
}
23
24