[][src]Crate amethyst_editor_sync

Provides functionality that allows an Amethyst game to communicate with an editor.

SyncEditorSystem is the root system that will send your game's state data to an editor. In order to visualize your game's state in an editor, you'll also need to create a SyncComponentSystem or SyncResourceSystem for each component and resource that you want to visualize. It is possible to automatically create these systems by creating a SyncEditorBundle and registering each component and resource on it instead.

Example

extern crate amethyst;
extern crate amethyst_editor_sync;
#[macro_use]
extern crate serde;

use amethyst::core::Transform;
use amethyst::ecs::*;
use amethyst::prelude::*;
use amethyst_editor_sync::*;

// Create a `SyncEditorBundle` which will create all necessary systems to send the components
// to the editor.
let editor_sync_bundle = SyncEditorBundle::new()
    // Register any engine-specific components you want to visualize.
    .sync_component::<Transform>("Transform")
    // Register any custom components that you use in your game.
    .sync_component::<Foo>("Foo");

let game_data = GameDataBuilder::default()
    .with_bundle(editor_sync_bundle)?;

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

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

Usage

First, create a SyncEditorBundle object. You must then register each of the component and resource types that you want to see in the editor:

  • For each component T, register the component with sync_component::<T>(name), specifying the name of the component and its concrete type.
  • For each resource, register the component with sync_resource::<T>(name), specifying the name of the resource and its concrete type.

Finally, add the SyncEditorBundle that you created to the game data.

Structs

EditorConnection

A connection to an editor which allows sending messages via a SyncEditorSystem.

EditorLogger

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

SerializableEntity

Helper type that wraps an Entity to provide serialization support.

SyncComponentSystem

A system that serializes all components of a specific type and sends them to the SyncEditorSystem, which will sync them with the editor.

SyncEditorBundle

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

SyncEditorSystem

A system that is in charge of coordinating a number of serialization systems and sending their results to the editor.

SyncResourceSystem

A system that serializes a resource of a specific type and sends it to the SyncEditorSystem, which will sync it with the editor.

Traits

ComponentSet
ResourceSet