[][src]Crate amethyst_editor_sync

Allows an Amethyst game to communicate with a visualizer/debugger.

This crate provides the hooks necessary for an Amethyst game to communicate with a visualizer/debugger running in another process. Once setup, it will send the game's state to the debugger, and can apply commands sent back.


In order to communicate with the editor, you must create a SyncEditorBundle and register all of the components and resources that you want to display or interact with in the debugger. Any component or resource that implements Serialize can be displayed, and any that implements Deserialize can also be modified at runtime within the debugger.

Create an empty bundle with SyncEditorBundle::new, and then use the various helper macros to register your custom types:

You can also use the SyncEditorBundle::sync_default_types method to register all of the types provided by Amethyst that can be supported by the debugger.

If you'd like a builder-like way of chaining method calls together in order to build your entire bundle in a single statement, we recommend using the tap crate to do so. The examples below demonstrate using tap in conjuction with the helper macros to succinctly register a variety of custom types.


extern crate amethyst;
extern crate amethyst_editor_sync;
extern crate serde;
extern crate tap;

use amethyst::ecs::*;
use amethyst::prelude::*;
use amethyst_editor_sync::*;
use serde::*;
use tap::*;

// Create a SyncEditorBundle which will create all necessary systems to send the components
// to the editor.
let editor_sync_bundle = SyncEditorBundle::new()

    // Register the default types from the engine.

    // Register any custom components and resources for your game. By default, components
    // and resources support reading and writing, allowing you to modify values at runtime
    // from the editor. If your component should be read-only, use the `read_*` variant
    // when registering the type.
    .tap(|bundle| sync_components!(bundle, MyComponent))
    .tap(|bundle| sync_resources!(bundle, MyResource))
    .tap(|bundle| read_resources!(bundle, ReadOnlyResource));

let game_data = GameDataBuilder::default()

// Make sure you enable serialization for your custom components and resources!
#[derive(Serialize, Deserialize)]
struct MyComponent {
    foo: usize,
    bar: String,

impl Component for MyComponent {
    type Storage = DenseVecStorage<Self>;

#[derive(Serialize, Deserialize)]
struct MyResource {
    baz: usize,

// This resource can't be deserialized because it contains an Entity.
// As such, we register it as read-only when setting up editor support.
struct ReadOnlyResource {
    important_entity: SerializableEntity,



Registers one or more components to be displayed as read-only in the editor.


Registers one or more resources to be displayed as read-only in the editor.


Registers one or more components to be syncronized with the editor.


Registers one or more resources to be synchronized with the editor.



A Log implementation that sends all incoming logs to the editor, which may allow more interactive filtering.


Helper type that wraps an Entity to provide serialization support.


Bundles all necessary systems for serializing all registered components and resources and sending them to the editor.