Cloud Code is a serverless compute service that allows you to write and run code in the cloud. You can use Unity's Cloud Code to write stateless server-side code on a fully managed infrastructure. Cloud Code is a fully managed service that automatically scales to meet your traffic demands. You can focus on the development of your game logic and isolate it from the client to prevent cheating.
Use Cloud Code with other Unity services to create a complete game backend, and to deploy solutions such as in-game economy, storage for player data, and dynamic settings configuration, while you keep your game logic secure.
Solutions with Cloud Code
|You need to deploy code to live games without rolling out a client update that would require players to update their installs.||Use Cloud Code to update your game logic without the need for players to update.|
|You want to ensure that malicious players can't alter the client code, change their state, or cheat. You might also want to prevent players from reverse-engineering your game logic.||Use Cloud Code to ensure that your game logic runs in a secure sandbox and is separate from the client.|
|You want to use multiple online services but don't want the game to feel sluggish and want it to be easy to write on the game client as you integrate with more server-side components.||Leverage Cloud Code to integrate with other Unity services and write code that ties in multiple components.|
|You need to manage infrastructure to run your game logic and scale it to meet your traffic demands.||Use Cloud Code to write stateless server-side code on a fully managed infrastructure.|
|You don't want to pay for unused resources when the game isn't receiving traffic.||Use Cloud Code to ensure that you only pay for what you use.|
|You need a solution for writing code that ties in multiple components without concern for authentication or compatibility.||Use Cloud Code to write code that integrates with other Unity services with built in compatibility.|
Use Cloud Code with modules and scripts
To call Cloud Code from games, you can use integrated Unity SDKs or use the Cloud Code Client API if you need to work outside of Unity Editor.
To choose which method fits your needs, review the following outline .
|Runtime||.NET 7||Node.js 14|
|Deploying||Editor, Command line or admin API.||Editor, dashboard, command line, or admin API.|
|Running||SDK or runtime API.||SDK or runtime API.|
|External library support||NuGet package manager and public internet endpoints||Public internet endpoints.|
Cloud Code interfaces
There are multiple ways to integrate and manage your application with Cloud Code:
|Cloud Code SDK||Scripts and modules.||A software development kit (SDK) to integrate your Unity project with Cloud Code.||Use the SDK to call module endpoints or to call scripts from Unity runtime.|
|Unity Cloud Dashboard||Scripts and limited modules support.||A web-based interface to manage Cloud Code configuration and settings.||Create, preview and test-run scripts and preview modules.|
|Unity Gaming Services command-line interface||Scripts and modules.||A command-line interface to manage Cloud Code configuration and settings.||Integrate Cloud Code into CI/CD and iterate with a file-based workflow to deploy Cloud Code alongside other Unity services.|
|Cloud Code Admin API||Scripts and modules.||A REST API to manage Cloud Code scripts and modules.||Create, read, update and delete Cloud Code scripts and modules using the REST API.|
|Cloud Code Client API||Scripts and modules.||A REST API to call Cloud Code scripts and module endpoints.||Call out to Cloud Code scripts and modules through an API call and integrate with products outside of Unity Editor.|
|Deployments||Scripts and modules.||An extension of Unity Editor and UGS CLI.||Use deployments to configure Cloud Code with files instead of the Unity Cloud Dashboard. Include these files as part of version control, and minimize context switching with the Unity Cloud Dashboard.|
To understand how to deploy and run your code, follow one of the options in the Take the next step section.
Take the next step
Cloud Code C# modules
Write server-side code with a type-safe programming language and powerful .NET components. Consume other content you need in the project bundling dynamic link libraries (DLLs) with tools like NuGet.