Get SpatialOS

Sites

Menu

C# worker SDK

The C# worker SDK allows anyone to write a worker in C# to connect to a SpatialOS simulated world. Like any other worker, a C# worker can subscribe to information for a part of a simulated world, visualize it, and perform some computation on behalf of the simulated world.

The SDK provides an API that allows you to connect to a simulated world, and send and receive component updates. It provides a lower-level API than the Unity3D integration. However, it gives you more flexibility, and can be used to build other integrations on top.

A typical C# worker makes use of both the core API defined in the Improbable.Worker namespace, and C# generated code based on the user-specified simulated world schema.

The SDK also includes methods to load and save snapshots of the entire simulation from and to a file. This lets you write tools to perform offline transformations of the simulation state, or to programmatically create the starting point of a simulation. This functionality is documented in the C# worker SDK docs.

If you’re using a game engine we don’t have an integration with, you can use this SDK (or one of the other language SDKs) to integrate that game engine with SpatialOS. See Integrating an engine for details.

C++ blank project

Have a look at the C++ blank project which is a good starting point for any project using the C++ SDK or when you need to add a C++ worker to an existing SpatialOS project.

Have a look at the C# blank project which is a good starting point for any project using the C# SDK or when you need to add a C# worker to an existing SpatialOS project.

Requirements

The C# worker SDK assumes that you have the 64-bit version of Mono installed on your machine, and that it is on your system path. This should include both mono the runtime, and xbuild. The SpatialOS deployment clusters have version 4.4.2.11-0xamarin1 or newer installed and on PATH, including the 64-bit version. This is the environment managed workers will run in.

Mono on Windows with MSBuild

Note that since version 5.0.0 Mono has a bug on Windows. This causes it not to include the C# compiler.

As a workaround for this bug, if you have compiler errors when building a worker, add MSBuild which comes with Visual Studio to your PATH environment variable before mono. This will cause Mono’s msbuild to use the csc compiler of MSBuild instead.

Mono on macOS

Note that the macOS version of Mono is distributed as a universal binary, which requires --arch=64 to be passed to the command line when launching your worker.

Clients

On Windows, client workers depend on the Visual C++ Redistributable for Visual Studio 2015.

Installation

This assumes you have completed the setup guide (Windows / macOS / Linux) already.

You can install mono using the mono-project.com installation guides: (Windows / macOS / Linux).

On Windows, Mono is required only for the generated build scripts.

On macOS, the C# worker SDK works with the latest Mono.

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums