Cloud Code C# modules
C# modules are C# libraries that the Cloud Code service can run to give you reusable server authoritative code. Unlike single scripts, these modules allow for multiple entry points and easier code reuse within the module. You can also create a main library and a data transfer object (DTO) library that both Cloud Code and your game can use to ensure that all data transferred between the Cloud Code client and your game use the same format.
Cloud Code C# modules cannot use classes from the UnityEngine
namespace or anything else in the Unity's scripting API. This is because Cloud Code uses the open-source .NET runtime. This is separate from the Unity runtime and does not rely on any of its scripting backends.
Typical workflow
The following process details a typical development cycle:
- Create a C# library project. Create the module project in the IDE that you're already familiar with for C# code.
- Write the code. Integrate with other Unity services by using the Cloud Code C# service SDKs.
- Test and debug. Create a unit test project for your module to validate that everything works as intended, or deploy the library on a development environment to test it with real user data.
- Deploy the module. Deploy the library via the CLI to make it available within Cloud Code.
- Integrate the module with your project. Import the Cloud Code SDK into your game and use one of the provided methods to call your script.
Topic | Description |
---|---|
Create a C# module | Learn about the different steps required to create a C# module project. |
Dependency injection | Learn how to decouple dependencies in your code and unit testing easier. |
Unit testing modules | Identify and fix issues early in the development process using unit testing. |
Service SDKs | Learn about connecting Cloud Code to other Unity services. |
Execution context | Use the IExecutionContext interface to provide you with extra information about the current call. |