Code Monkey home page Code Monkey logo

bevy_asset_ron's Introduction

Custom RON Assets for Bevy

This crate allows you to easily register arbitrary custom data to be loaded by Bevy as an Asset, from files using the RON format.

It minimizes the amount of boilerplate needed for such custom asset types.

You only need to derive the required traits on your custom type, and add a RonAssetPlugin to your App!

Caveat: you need to come up with a unique file name extension for each new asset type. Bevy also requires a unique UUID for TypeUuid.

#[derive(serde::Deserialize)]
#[derive(TypeUuid)]
#[uuid = "1df82c01-9c71-4fa8-adc4-78c5822268f8"]
struct GameItemDescriptionAsset {
    damage: f32,
    durability: f32,
    min_level: u8,
}

fn main() {
    App::build()
        // bevy
        .add_plugins(DefaultPlugins)
        // our asset
        .add_plugin(
            // load `*.item` files
            RonAssetPlugin::<GameItemDescriptionAsset>::new(&["item"])
        )
        .add_startup_system(setup.system())
        .run();
}

fn setup(server: Res<AssetServer>) {
    // load our item configs!
    let handles = server.load_folder("items");

    // TODO: store the handles somewhere
}

Now you can just create files like assets/items/big_gun.item:

(
  damage: 25.0,
  durability: 170.0,
  min_level: 4,
)

See examples/load_rons.rs for a more elaborate example!

$ cargo run --example load_rons

Compatible Bevy versions

Compatibility of published bevy_asset_ron versions:

bevy_asset_ron bevy
0.3.0 0.6
0.2.0 0.5
0.1.0 0.4

bevy_asset_ron's People

Contributors

inodentry avatar miniaczq avatar nrot avatar rparrett avatar rsaihe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.