bevy_gltf_save_load
Built upon bevy_gltf_blueprints this crate adds the ability to easilly save and load your game worlds for Bevy .
- leverages blueprints & seperation between
- dynamic entities : entities that can change during the lifetime of your app/game
- static entities : entities that do NOT change (typically, a part of your levels/ environements)
- and allows allow for :
- a simple save/load workflow thanks to the above
- ability to specify which entities to save or to exclude
- ability to specify which components to save or to exclude
- ability to specify which resources to save or to exclude
- small(er) save files (only a portion of the entities is saved)
Particularly useful when using Blender as an editor for the Bevy game engine, combined with the Blender plugin that does a lot of the work for you (including spliting generating seperate gltf files for your static vs dynamic assets)
A bit of heads up:
- very opinionated !
- still in the early stages & not 100% feature complete
- fun fact: as the static level structure is stored seperatly, you can change your level layout & still reload an existing save file
Usage
Here's a minimal usage example:
# Cargo.toml
[]
="0.13"
= "0.4"
= "0.10" // also needed
use *;
use *;
// add a system to trigger saving
// add a system to trigger loading
// setting up your world
// on initial setup, the static entities & the dynamic entities are kept seperate for clarity & loaded as blueprints from 2 seperate files
take a look at the example for more clarity
Installation
Add the following to your [dependencies] section in Cargo.toml:
= "0.3"
= "0.10" // also needed, as bevy_gltf_save_load does not re-export it at this time
Or use cargo add:
Setup
use *;
use *;
you likely need to configure your settings (otherwise, not much will be saved)
use *;
use *;
How to make sure your entites will be saved
- only entites that have a Dynamic component will be saved ! (the component is provided as part of the crate)
- you can either add that component at runtime or have it baked-in in the Blueprint
Component Filter:
-
by default only the following components are going to be saved
- Parent
- Children
- BlueprintName : part of bevy_gltf_blueprints, used under the hood
- SpawnHere :part of bevy_gltf_blueprints, used under the hood
- Dynamic : included in this crate, allows you to tag components as dynamic aka saveable ! Use this to make sure your entities are saved !
-
you CANNOT remove these as they are part of the boilerplate
-
you CAN add however many other components you want, allow them all etc as you see fit
-
you can find more information about the SceneFilter object here and here
Events
- to trigger saving use the
SaveRequestevent
// add a system to trigger saving
- to trigger loading use the
LoadRequestevent
// add a system to trigger saving
- you also notified when saving / loading is done
SavingFinishedfor savingLoadingFinishedfor loading
Note: I highly recomend you change states when you start/finish saving & loading, otherwise things will get unpredictable Please see the example for this.
Additional notes
- the name + path of the static level blueprint/gltf file will be saved as part of the save file, and reused to dynamically load the correct static assets, which is necessary when you have multiple levels, and thus all required information to reload a save is contained within the save
SystemSet
For convenience bevy_gltf_save_load provides two SystemSets
Examples
Highly advised to get a better understanding of how things work ! To get started I recomend looking at
All examples are here:
Compatible Bevy versions
The main branch is compatible with the latest Bevy release, while the branch bevy_main tries to track the main branch of Bevy (PRs updating the tracked commit are welcome).
Compatibility of bevy_gltf_save_load versions:
bevy_gltf_save_load |
bevy |
|---|---|
0.4 |
0.13 |
0.1 -0.3 |
0.12 |
branch main |
0.12 |
branch bevy_main |
main |
License
This crate, all its code, contents & assets is 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)