bevy-contrib-inspector

Crates.io version docs.rs docs Download


This crate provides the ability to annotate structs with a #[derive(Inspectable)], which opens a web interface (by default on port 5676) where you can visually edit the values of your struct live.

Your struct will then be available to you as a bevy resource.

Your image title

Example

```rust use bevycontribinspector::Inspectable;

[derive(Inspectable, Default)]

struct Data { shouldrender: bool, text: String, #[inspectable(min = 42.0, max = 100.0)] size: f32, } Add the `InspectorPlugin` to your App. rust use bevycontrib_inspector::InspectorPlugin;

fn main() { App::build() .adddefaultplugins() .addplugin(InspectorPlugin::::new()) .addsystem(your_system.system()) // ... .run(); }

fn yoursystem(data: ChangedRes, mut query: Query<...>) { /* */ } `` To automatically open the webbrowser when starting, run your program usingBEVYINSPECTOR_OPEN=1 cargo run`.

Attributes

When deriving the Inspectable trait, you can set options such like the port the server will run on like so: ```rust

[derive(Inspectable, Default)]

[inspectable(port = 1234)]

struct Data { #[inspectable(a = 1, b = 2, c = 3)] field: Type, } `` The attribute on the struct will accept fields of the typeInspectableOptions, while the attributes on the fields accept those of their::Options`.

Features

native: Instead of opening the inspector window in a browser, start a webkit2gtk window.

On ubuntu, the feature requires sudo apt install libwebkit2gtk-4.0-dev