Skip to content

Cargo-generate template for Bevy projects

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

taurr/bevy-template-rs

Bevy-template-rs

This is a small but feature rich set of cargo-generate templates for use when creating Bevy applications.

Templates/Features

  • Binary template for the main game binary.

    • Complete with camera setup, a very small 2D or 3D system and debug diagnostics.
    • Includes integration test support - Small test with Bevy in headless mode.
    • Optionally includes setup of vscode tasks.
    • Cargo runner configured to use WASM Server Runner in case of WASM target (wasm32-unknown-unknown)
    • Will utilize fast compiles as described in The Bevy Book when built using the vscode tasks (not for WASM target).
      • if not using vscode, just use cargo build --features bevy/dynamic.
    • If enabling the feature inspector, the project will attempt to use [bevy-inspector-egui] (works with WASM).
    • If enabling the feature editor, the project will attempt to use bevy_editor_pls.
    • WASM target goes fullscreen (or rather window)
    • Adjusts if expanded inside a existing cargo project.
  • Library template for a small library crate.

    • Includes integration test support - Small test with Bevy in headless mode.
    • Optionally includes setup of vscode tasks.
    • Adjusts if expanded inside a existing cargo project.
  • Minimal template

    • Minimal application template. Really only the basics for a project (Though still with WASM support).
  • Workflow template.

    • Add a copy of the Official Bevy Workflow template to an existing project.
    • Template requires cargo-generate to be invoked with the --init parameter as it is not inteded as a complete project. The template must be expanded inside an existing project.

Usage

To expand e.g a binary project, use:

cargo generate taurr/bevy-template-rs Binary

To include Github workflow files, use:

cd <PROJECT_DIR>
cargo generate taurr/bevy-template-rs Workflow --init --name <BINARY NAME>

Why the --init parameter? Well thats just to tell cargo-generate not to create a folder for the generated files.

For further usage, or if having issues with cargo-generate, please have a look in the cargo-generate book.

Template expansion

Requirements

cargo-generate must be installed. The easiest way to do this is:

cargo install cargo-generate

💡 Tips'n'tricks

If the template is used on a regular basis, cargo-generate allows to setup favorite templates and default variables.

To do this, open or create the file $CARGO_HOME/cargo-generate.toml, insert this:

[values]
gh_username = "<YOUR GITHUB USERNAME>"
ide = "vscode|none"

[favorites.bevy-bin]
git = "https://github.com/taurr/bevy-template-rs"
subfolder = "Binary"

[favorites.bevy-lib]
git = "https://github.com/taurr/bevy-template-rs"
subfolder = "Library"

[favorites.bevy-wf]
git = "https://github.com/taurr/bevy-template-rs"
subfolder = "Workflow"
is_init = true

After this, the template can be expanded using cargo generate bevy-bin, cargo generate bevy-lib or cargo generate bevy-wf.

⚠️ Adding the workflow template through this favorite will no longer require the --init parameter, and thus will always expand in the current directory!

About

Cargo-generate template for Bevy projects

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks