A simple Bevy plugin that adds a LocalStorage
asset reader.
The example is a separate crate because trunk
does not support cargo examples yet.
cd example_crate
trunk serve
- requires trunk:
cargo install --locked trunk
- requires
wasm32-unknown-unknown
target:rustup target add wasm32-unknown-unknown
- this will serve your app on
8080
and automatically rebuild + reload it after code changes
Add the plugin before DefaultPlugins
.
App::new()
.add_plugins((
LocalStorageAssetReaderPlugin {
asset_id: "local",
},
DefaultPlugins,
));
You can now load assets from local storage like so:
commands.spawn(DynamicSceneBundle {
scene: asset_server.load(format!("local://example.scn.ron")),
..default()
});
Write to local storage like so.
use bevy_local_storage::get_local_storage;
// Get a local storage instance
// PANICS: if local storage not present
let local_storage: web_sys::Storage = get_local_storage();
// Write to local storage
local_storage.set_item("example.scn.ron", SCENE_DATA).unwrap();
See web-sys::Storage for more methods.
bevy_local_storage |
bevy |
---|---|
0.2 |
0.14 |
0.1 |
0.13 |
Dual-licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.