Local Cloud Code server
Start a Cloud Code server directly on your local machine.
Read time 3 minutesLast updated a day ago
You can accelerate back-end development by instantiating a Cloud Code server with C# modules deployed directly on your local machine. With this local Cloud Code server, you can iterate rapidly on game server logic in isolation, bypassing the need to push to a remote environment for every change.
More importantly, a local Cloud Code server unlocks diagnostic capabilities by allowing you to attach a debugger to the local process, granting the ability to set breakpoints, step through execution, and inspect memory to resolve complex server issues at runtime in Play mode.
Prerequisites
Before you start, make sure your project meets the following prerequisites:- Unity 6.3 or later.
- Follow the Cloud Code modules steps to set up the Unity Editor.
- If you have existing modules, ensure you reference the following NuGet packages:
- v0.0.26 or later
com.unity.services.cloudcode.apis - v0.0.4 or later
com.unity.services.cloudcode.core
- You have .Net 9.0 (Microsoft) installed on your machine.
Local Cloud Code Toolbar button
You can access all local server settings and operations through the Cloud Code Toolbar button. This button is disabled by default. To enable the Cloud Code Toolbar button:- If not already done, update your scripting define symbols.
- In the Editor, go to Edit > Project Settings > Player.
- Under Script Compilation > Scripting Define Symbols, select +.
- Enter .
UNITY_SERVICES_CLOUDCODE_EXPERIMENTAL - Select Apply, then save your project.
- Select the More (⋮) menu in the Toolbar.
- Select Services > Cloud Code.

Enabling Cloud Code in the Editor from the Toolbar
Executing modules on the local server
To execute C# server functions on the local server from your game, select the Cloud Code Toolbar button, then Start Local Server.
The Start Local Server button in the Toolbar

The Stop Local Server button in the Toolbar

Redeploying a module in the Deployment window
Local state persistence
The default behavior of scoped data on a local server is to persist even after you restart the server or redeploy a module. However, in certain situations, your development scenario might require you to reset the data of yourPlayerMultiplayerSession- Select the Cloud Code Toolbar button.
- If your server is currently running, select Stop Local Server.
- For the Local Server State option, select Clear.

The Local Server State Clear button in the Toolbar
Additional local server settings
You can configure the local server with the following additional settings before starting it:- Port: The local port on your machine on which your local server will listen for calls.
- Secrets file: A JSON asset containing key-value secret pairs to be retrieved in your Cloud Code functions.

The Cloud Code Project Settings window
ModuleConfigpublic class ModuleConfig : ICloudCodeSetup{ public void Setup(ICloudCodeConfig config) { // Old approach - will be deprecated, please remove. // config.Dependencies.AddSingleton<IGameApiClient>(GameApiClient.Create()); // Replace with this for version v0.0.26+ config.AddGameApiClient(); }}