---
title: Shared rules library
product: Cloud Code
version: 3.0.0
latest_version: 3.0.0
status: This page documents version 3.0.0. The latest version is 3.0.0.
canonical: https://docs.unity.com/en-us/cloud-code/3.0.0/cloudbehaviours/sharing-game-rules/shared-rules-library
latest_url: https://docs.unity.com/en-us/cloud-code/3.0.0/cloudbehaviours/sharing-game-rules/shared-rules-library.md
last_updated: 2026-10-23
generated_at: 2026-11-04T17:12:01.657Z
locale: en-us
---

# Shared rules library

> Share rule logic between your client and your CloudBehaviour by putting it in a shared assembly.

> **Important:**
>
> This page describes an experimental feature that might change significantly before release. It's not recommended to use or rely on experimental features in production environments due to potential instability.

When [synchronized rule outcomes](./sync-metadata-approach.md) can no longer represent your rules, share your rule logic directly instead of re-implementing it on both sides. Put the shared logic in its own assembly, and reference that assembly from both your client assembly and your CloudBehaviour's cloud assembly. On deploy, the build bundles the shared assembly into your Cloud Code module automatically, so you write the rule once.

A model type that crosses the client boundary through the client bindings carries only data. A type in a shared assembly keeps its methods on both sides, because the client references the real assembly instead of a generated, data-only stub.

## Set up a shared rules library

To set up a shared rules library:

1. [Create an assembly definition](https://docs.unity3d.com/Manual/assembly-definitions-creating.html) for your shared code, separate from your cloud and client assemblies.
2. In the **Inspector** window of the shared assembly, enable **No Engine References**. This setting is required. The cloud assembly can't reference `UnityEngine` types, so the shared assembly can't either. If your cloud script uses a type from an assembly that references the Unity Engine or the Unity Editor, the build fails with `CCSG130`.
3. [Add the shared assembly](https://docs.unity3d.com/Manual/assembly-definitions-referencing.html) to the **Assembly Definition References** list of both your cloud assembly and your client assembly.
4. Put your shared rule logic and data types in the shared assembly, using plain C#.

After you add the shared assembly to both **Assembly Definition References** lists, your cloud and client code can reference the same types directly.

The following example shows a minimal shared assembly definition:

```json title="Shared assembly definition"
{
    "name": "MyGameShared",
    "noEngineReferences": true
}
```

The following shared type carries a real method, not only data, because both your cloud and client assemblies reference it directly:

```csharp title="Shared/MoveResult.cs"
namespace MyGame.Shared
{
    public class MoveResult
    {
        public bool WasLegal;
        public int Column;

        public string Describe() => WasLegal ? $"Placed at column {Column}" : "Move rejected";
    }
}
```

Both your cloud class and your client code can now call `Describe()`, and they run the same source code instead of two separate implementations. Results are identical as long as the code doesn't depend on runtime-specific behavior, such as culture settings or floating-point precision.

## Bundle referenced assemblies

When you deploy your module, the build bundles your shared assembly and everything it references into the module, the same way it bundles your cloud assembly's own references. To bundle a precompiled DLL, enable **Override References** on the shared assembly and add the DLL to its **Assembly References** list. The build doesn't bundle DLLs that Unity references automatically.

## Additional resources

* [Sharing game rules](../sharing-game-rules)
* [Synchronized rule outcomes](./sync-metadata-approach.md)
* [Synchronized state in CloudBehaviours](../synchronized-state)
