# Get started

> Follow this workflow to create a Unity Cloud Code module in the Unity Editor and deploy it to the Cloud Code service.

This page describes the steps to create a Unity Cloud Code module (UCCM) in the Unity Editor and deploy it to the Cloud Code service.

> **Note:**
>
> The Unity Cloud Code module (UCCM) workflow requires Unity 6.7 or later.

The examples in the workflow create a simple Hello World module. To get started with Cloud Code modules, follow these steps:

1. [Set up the Unity Editor:](#set-up-the-unity-editor) Link your Unity Gaming Services project with the Unity Editor, and install the required packages.
2. [Create a Unity Cloud Code module:](#create-a-unity-cloud-code-module) Create and compile a module directly in the Editor.
3. [Deploy the module:](#deploy-the-module) Deploy the module to the Cloud Code service, or run it on a local Cloud Code server for testing.
4. [Call the module function from your game:](#call-a-module-function-from-your-game) Call the module endpoint from your game client.

> **Note:**
>
> This guide uses the Unity Cloud Code module (UCCM) workflow, the recommended way to author modules in the Unity Editor. For other authoring methods, refer to [Develop modules](./how-to-guides/write-modules.md). To author with a linked C# solution instead, refer to [Develop modules with a reference file](./how-to-guides/write-modules/unity-editor-module-reference.md).

## Video walkthrough

Watch the following video for a walkthrough of creating and deploying a C# module in the Unity Editor.

> **Note:**
>
> This video demonstrates the [module reference workflow](./how-to-guides/write-modules/unity-editor-module-reference.md), an alternative to the Unity Cloud Code module workflow that this guide describes.


**Frame:**

[Getting started with Cloud Code video](https://www.youtube.com/embed/l_iD06qOu6Q?si=3Vun1hTRqLY_fhCB)

## Set up the Unity Editor

To create Cloud Code modules within the Editor, you need to install the required packages and link your Unity Gaming Services project with the Unity Editor.

### Access Cloud Code in the Unity Dashboard

To access Cloud Code in the Unity Dashboard, do the following:

1. In the [Unity Dashboard](https://cloud.unity.com), go to **Development** > **Products**.
2. Select **Cloud Code**.

### Link project

Link your [Unity Gaming Services project](/cloud/projects.md) with the Unity Editor. You can find your UGS project ID in the [Unity Dashboard](https://cloud.unity.com).

If you create a new Unity project, you can link your Unity Gaming Services project with the Unity Editor during the project creation process.

If you're working with an existing Unity project, you can link your Unity Gaming Services project with the Unity Editor from the Services window.

1. In Unity Editor, select **Edit** > **Project Settings** > **Services**.

2. Link your project.
   If your project doesn't have a Unity project ID:

   1. Select **Create a Unity Project ID** > **Organizations**, then select an organization from the dropdown.
   2. Select **Create project ID**.

   If you have an existing Unity project ID:

   1. Select **Use an existing Unity project ID**.
   2. Select an organization and a project from the dropdowns.
   3. Select **Link project ID**.

Your Unity Project ID appears, and the project is now linked to Unity services.

### Install required packages

To create Cloud Code modules within the Editor, you need to install the following packages:

* Deployment (`com.unity.services.deployment`)
* Cloud Code (`com.unity.services.cloudcode`), version 3.0.0 or later

To install each package, follow the steps in [Install a UPM package by name](https://docs.unity3d.com/Manual/upm-ui-quick.html), and enter the package name from the preceding list.

### Install and set up .NET

To deploy Cloud Code modules in the editor you need to install [.NET](https://dotnet.microsoft.com/en-us/).

To set your default .NET path in editor, use the following steps:

1. In the Unity Editor, open the Preferences window.
   * On Windows, select **Edit** > **Preferences..** > **Cloud Code**.
   * On macOS, select **Unity** > **Settings..** > **Cloud Code**.
2. In the **.NET development environment** section, modify your **.NET path** to the one you have installed.
3. Select **Apply**.

### Set up the Deployment window

The Deployment window allows you to deploy Cloud Code modules to your remote environment.

If you installed the Deployment package, you can access it from the Unity Editor.

* In Unity Editor versions 2021.3+, select **Window** > **Deployment**.
* In Unity Editor versions 2022+, select **Services** > **Deployment**.

Before you can use the Deployment window, you need to select the environment you want to deploy to:

1. In the Unity Editor, open the [**Deployment window**](#set-up-the-deployment-window).
2. In the Deployment window, select **Deployment Settings**.
3. In the new Environments window, select an environment from the **Editor Environment** dropdown.

## Create a Unity Cloud Code module

Create a Unity Cloud Code module (UCCM) directly in the Editor. For the full procedure and details about the generated files, refer to [Develop Cloud Code modules in the Unity Editor](./how-to-guides/write-modules/unity-editor.md). To learn how a module is structured, refer to [module structure](./how-to-guides/module-structure.md).

## Deploy the module

To make your module endpoints accessible to the game client, deploy the module to the Cloud Code service. For the deployment steps, refer to [Deploy the module](./how-to-guides/write-modules/unity-editor.md#deploy-the-module).

To test module changes on your machine without deploying them, run a local Cloud Code server instead. For more information, refer to [Run a local Cloud Code server](./how-to-guides/local-cloud-code-server.md).

## Call a module function from your game

To verify that your module works, call a module endpoint from your game client. The call goes to the Cloud Code service, or to your local Cloud Code server if it's running when you enter Play mode. The following example calls a `SayHello` function.

### SDK setup

To call a module function from your game, you first need to set up the Cloud Code SDK in your game client.

1. Ensure the service is enabled via the Cloud Code page in the [Unity Dashboard](https://cloud.unity.com).
2. Ensure that you have installed both the Cloud Code and the Authentication SDKs from the Unity Package Manager.
3. Create a new C# Monobehaviour script in Unity Editor. For more information, refer to [Creating and using scripts](https://docs.unity3d.com/Manual/CreatingAndUsingScripts.html) in the Unity Manual.

> **Note:**
>
> Players must have a valid player ID and access token to access the Cloud Code services. You need to authenticate players with the Authentication SDK before you use any of the Cloud Code APIs.

### Call the module function

The following example shows how to call the module function `SayHello` from the module `HelloWorld` within your game client.

*C#*

```cs
using Unity.Services.Authentication;
using Unity.Services.CloudCode;
using Unity.Services.CloudCode.GeneratedBindings;
using Unity.Services.Core;
using UnityEngine;

public class TestModule : MonoBehaviour
{
    private async void Start()
    {
        // Initialize the Unity Services Core SDK
        await UnityServices.InitializeAsync();

        // Authenticate by logging into an anonymous account
        await AuthenticationService.Instance.SignInAnonymouslyAsync();

        try
        {
            // Call the function within the module and provide the parameters we defined in there
            var module = new HelloWorldBindings(CloudCodeService.Instance);
            var result = await module.SayHello("World");

            Debug.Log(result);
        }
        catch (CloudCodeException exception)
        {
            Debug.LogException(exception);
        }
    }
}
```

To run the example:

1. Attach the `TestModule` script to a GameObject in your scene.
2. If you use a local Cloud Code server, make sure that it's running. Refer to [Execute modules on the local server](./how-to-guides/local-cloud-code-server.md#execute-modules-on-the-local-server).
3. In the toolbar, select **Play** to enter Play mode.

The **Console** window displays the result of the `SayHello` call.

> **Important:**
>
> If a module hasn't received any traffic in the last 15 mins, you might experience a cold start latency. Any subsequent calls to the module are faster.

## Next steps

Learn about the next steps after deploying your first module.

| **Topic**                                                                            | **Description**                                     |
| ------------------------------------------------------------------------------------ | --------------------------------------------------- |
| [Module structure](./how-to-guides/module-structure.md)                              | Familiarize yourself with module structure.         |
| [Run a local Cloud Code server](./how-to-guides/local-cloud-code-server.md)          | Test module changes without deploying them.         |
| [Stateful Cloud Code](./stateful-cloud-code.md)                                      | Persist game state across module function calls.    |
| [Integrate with other Unity services](./how-to-guides/unity-services-integration.md) | Integrate modules with other Unity Gaming Services. |
| [Integrate with external services](./how-to-guides/external-services-integration.md) | Integrate modules with external services.           |
| [Write unit tests](./how-to-guides/unit-testing.md)                                  | Write unit tests for your modules.                  |
| [In-memory cache](./how-to-guides/in-memory-cache.md)                                | Cache slow-changing data between module endpoints.  |
