Skip to content

A LocalStorage asset reader for Bevy.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

robertdodd/bevy_local_storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bevy Local Storage

A simple Bevy plugin that adds a LocalStorage asset reader.


Example

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

Usage

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 LocalStorage

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.

Compatible Bevy versions

bevy_local_storage bevy
0.2 0.14
0.1 0.13

License

Dual-licensed under either of

at your option.

Contribution

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.

About

A LocalStorage asset reader for Bevy.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published