Cloud Code JavaScript scripts
Cloud Code scripts use JavaScript. You can call these scripts from games built with Unity, or from any other client or server.
Authoring method | Description |
---|---|
Unity Cloud Dashboard | Use the Unity Cloud Dashboard to create and test scripts. You can access other Unity Gaming Services from the same place, such as Remote Config. |
Unity Editor | Use the Unity Editor to write, test and bundle scripts. You can integrate with the deployment window, automate your workflow and deploy Cloud Code alongside other Unity services. |
Unity Gaming Services CLI | Use the CLI to deploy and manage scripts from the command line. Deploy multiple Unity service configurations at once, and integrate with CI/CD. |
Typical workflow
The following process details a typical development cycle:
- Create a script. Create a Cloud Code script through the Unity Cloud Dashboard and add custom parameters.
- Write the code. Build from the example scripts or start from scratch. Easily integrate with other Unity Gaming Services by using the Cloud Code JavaScript SDKs.
- Test and debug. Select Run on the dashboard and test the result of your function. Use the provided test players to validate the interaction with other services or add logging statements to debug issues. For more information, refer to the page on how to Test run the script.
- Publish the script. Select Publish to make the script available to the game client. This is the main mechanism for adding live updates on scripts, which immediately display in the game.
- Integrate the script with your project. Import the Cloud Code SDK into your game and call your script from Unity runtime. You can run the script with the REST API, or from a Multiplay server.
Example use cases
You can write a lot of your game logic with Cloud Code. For example, you can connect to different services from within scripts. To understand how to connect to services and how it works as a game mechanic, you can explore the use cases. The examples include server time anti-cheat mechanisms, in-game coupons, and daily rewards.
For more advanced use, download the Unity Gaming Services Samples project to learn how to solve common game development challenges with Cloud Code, and read the Advanced use cases.
Fundamental concepts
Learn about the fundamental concepts of Cloud Code scripts:
Topic | Description |
---|---|
Create a script | Learn how to create a script. |
Script structure | Understand the structure of a script. |
Write scripts | Learn how to write scripts using the Unity Cloud Dashboard, UGS CLI, REST API or the Unity Editor. |
Run scripts | Learn how to run scripts from Unity runtime, with REST API or from a Multiplay server. |
Test run the script | Learn how to test your script. |
Error handling | Learn how handle errors in your scripts. |
Logging | Learn how to use logging to debug your script. |
Improve your workflow
To streamline the development and deployment of your scripts, you can automate the process:
Topic | Description |
---|---|
Integrate with CI/CD | Integrate the deployment of your script with your CI/CD pipeline. |
Integrate with Unity Editor | Learn how to write, test and bundle scripts in the Unity Editor. |
Integrate further
You can integrate modules with other Unity Gaming Services and any external services, and access cross-player data.
To integrate with other services, you can install the Cloud Code JavaScript libraries or use a HTTP client.
Topic | Description |
---|---|
Authentication | Learn how to authenticate your game client with Cloud Code. |
Service and access token support | Learn how to use service and access tokens to authenticate your scripts. |
Available libraries | Find the available UGS SDKs for with Cloud Code scripts. |
Access control | Learn how to control access and prevent unwanted usage. |
Integrate with Unity Services | Learn about how to connect Cloud Code to other Unity services. |
Integrate with external services | Learn how to integrate with external services. |
Interact with cross-player data | Learn how to access and update data for other players. |
Triggers | Learn how to use triggers to automate server side actions. |