The C# bindings are language bindings in C# for the Worker SDK in C. They are intended for the same use cases as the Worker SDK in C, in environments that require C# or other .Net Framework languages.

The set of C# bindings is the simplest possible wrapper around the Worker SDK in C, and are designed with performance in mind (for example, as little overhead for the interop as possible, avoid C# allocations as much as possible). They are unopinionated and, for implementations using the .NET Framework, they are the Worker SDK option that gives you the most control.

Recommended for:

  • integration into a C# game engine for production use.
  • development of a C# higher-level, opinionated abstraction layer on top of SpatialOS for production use (for example the .NET Core C# Worker (preview)).
  • production use of C# workers that you create without using a game engine (likely via a suitable abstraction).

May also be suitable for:

  • understanding SpatialOS’s concepts and abstractions.
  • evaluating SpatialOS’s capabilities.

Not recommended for:

Like any other worker type, a worker type written with C# bindings can subscribe to information for a part of a SpatialOS simulated world, visualize it, and perform some computation on behalf of the simulated world.

Unlike C++, (high-level) C#, and Java, the Worker SDK C# bindings do not provide any generated code. Instead, they expose serialization functions to read and write:

  • component data
  • component updates
  • command requests and responses.

This requires substantially more work to get started, because you will likely need to implement code generation yourself using custom codegen. However, this approach enables far more flexibility. For example, you could write fully dynamic serialization code which uses reflection (perhaps after being validated using some custom generated code based off the project's schema.

In addition to connecting to a simulation, the API also includes methods to load and save snapshots of the entire simulation from and to a file. This means you can write tooling to modify the state of the simulation offline, or programmatically create the initial point of a simulation.

Using the example project

Currently, there is no dedicated example project using the C# bindings, but you can use the C example project for a fairly minimal example of project structure and build configuration for workers using the Worker SDK in C. We recommend you use it as a starting point, along with Setup and installation and Building a worker, and replace C calls with their respective C# counterparts.

Game engine integrations

The APIs are lower-level than a game engine integration such as the GDK for Unity.

If you're using a game engine that we don't have an integration with, you can use this API to integrate that game engine with SpatialOS. See Integrating a game engine with SpatialOS for details.

2019-11-25 Page added with limited editorial review.

Updated 4 months ago


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.