# Develop Cloud Code modules in the Unity Editor

> Create, compile, and deploy Cloud Code modules in the Unity Editor as Unity Cloud Code modules (.ccmu).

You can create, compile, and deploy Cloud Code modules entirely within the Unity Editor. A module created in this way is called a Unity Cloud Code module (UCCM), and its asset file carries the `.ccmu` extension.

UCCMs are the recommended way to author Cloud Code modules in the Unity Editor. They bring the entire module workflow into the Editor, automating some processes and improving iteration time, and build on the same logic and concepts as the [module reference workflow](./unity-editor-module-reference.md), with the following additional key features:

* Develop Cloud Code modules using the standard Unity Editor [script workflow](https://docs.unity3d.com/Manual/inspecting-scripts.html). Scripts are created and compiled directly in the Editor, but their contents are edited in your [currently configured External Script Editor](https://docs.unity3d.com/Manual/preferences-external-tools.html).
* Unity Cloud Code modules compile automatically during the standard Editor compilation pass, so you don't have to [manually generate bindings](./unity-editor-module-reference.md#generate-bindings).
* Debugging is built-in by default and integrated into the Editor.

> **Note:**
>
> Use the [module reference workflow](./unity-editor-module-reference.md) only if you maintain an existing module solution or prefer to link a separate C# project.

## Prerequisites

Before you create a Unity Cloud Code module, set up the Unity Editor and install the required packages. Follow the [set up the Unity Editor](/cloud-code/3.0.0/modules/getting-started.md#set-up-the-unity-editor) steps in the Cloud Code modules getting started guide.

> **Note:**
>
> Authoring Unity Cloud Code modules requires Unity 6.7 or later.

## Create a Unity Cloud Code module

You can create a new UCCM directly within the Unity Editor.

To create a Unity Cloud Code module:

1. In the **Project** window, select or create a folder to contain your module.
2. Right-click in the folder, then select **Create** > **Services** > **Cloud Code Module Script**. The Cloud Code Script appears in your folder.
3. Optionally rename the script, then press **Enter** to accept the script.
4. In the **Cloud Code Module Creator** dialog that opens, select the **Cloud** tab, where you can do the following:
   * In the **Cloud Code Script** field, optionally rename the C# script.
   * In the **Cloud Code C# Module** field, optionally rename the module.
5. Verify the remaining paths and file names for the other resources in the **Cloud** and **Client** tabs.
6. Select **Confirm**.
7. If required, repeat steps 1 to 3 to create another script. Creating a script in the same folder automatically adds it to the module.

The previous procedure generates the following:

* A `Cloud` folder containing a Cloud Code script and an [Assembly Definition](https://docs.unity3d.com/Manual/assembly-definitions-creating.html). Write your module logic here. You can add more scripts to this folder.
* A `Client` folder containing a client script and an Assembly Definition. This client script is an empty partial class containing a reference to a generated file that's updated automatically from your Cloud Code scripts.
* A Unity Cloud Code module asset (`.ccmu`) in the parent folder, pointing to both Assembly Definitions. Use this file to deploy the module in the [**Deployment** window](https://docs.unity3d.com/Packages/com.unity.services.deployment@latest/index.html?subfolder=/manual/deployment_window.html).

> **Warning:**
>
> The Client classes are partial classes because Cloud Code uses source generation to create client-side bindings for your game to call cloud functions. Because the Client script is automatically generated, don't modify it directly, as doing so can break your game.

## Deploy the module

The module appears in the **Deployment** window as a Cloud Code Module. From the **Deployment** window, you can deploy the module to a remote environment or to a [local Cloud Code server](/cloud-code/3.0.0/modules/how-to-guides/local-cloud-code-server.md) if you have one running.

The following diagram shows how a module moves through deployment. The diagram also demonstrates how a function call routes to the Cloud Code service or a local server, depending on whether the local server is running when you enter Play mode.

```mermaid
%%{init: {'themeCSS': '.cluster-label { font-size: 18px; font-weight: bold; }', 'flowchart': { 'subGraphTitleMargin': { 'top': 10, 'bottom': 20 } }}}%%
flowchart TB
    subgraph s1["1. Build and deploy a module"]
        direction LR
        A["<b>Create Cloud Code module</b><br/>C# library (.sln)"] --> B["<b>Create module usage</b><br/>.ccmu (native, in Editor)"]
        A --> C["<b>Create module reference</b><br/>.ccmr (external solution)"]
        B --> D["<b>Deployment window</b><br/>Deploy module, generate bindings"]
        C --> D
        D -->|Deploy to cloud| E["<b>Cloud Code service</b><br/>Remote, in UGS"]
        D -->|Deploy to local| F["<b>Local Cloud Code server</b><br/>On your machine"]
    end

    subgraph s2["2. Route the function call"]
        direction LR
        G["Enter Play mode"] --> H{"Local server running?"}
        H -->|No| I["Calls route to<br/>Cloud Code service"]
        H -->|Yes| J["Calls route to<br/>Local Cloud Code server"]
    end

    E ~~~ G
    F ~~~ G
```

To deploy the module to a remote environment:

1. In the Unity Editor, open the [**Deployment** window](https://docs.unity3d.com/Packages/com.unity.services.deployment@latest/index.html?subfolder=/manual/deployment_window.html).
2. Select the Cloud Code Module.
3. Select **Deploy Selected**.

A successful deployment shows a green checkmark next to the module in the **Deployment** window.

> **Note:**
>
> After a remote deployment, the Cloud Code invokers need a short time to download the updated module. Until they do, calls might still run the previous version of the module. Wait briefly after the deployment completes before you enter Play mode to test your changes.

> **Tip:**
>
> When you test [Stateful Cloud Code](/cloud-code/3.0.0/modules/stateful-cloud-code.md) on a local server, you can reset persistent states directly from the **Cloud Code** Toolbar button to return your game to its default state.

To learn how to call your deployed module endpoints from your game, refer to [Run modules in Unity Runtime](../run-modules/unity-runtime#use-editor-bindings).
