> For the complete documentation index, see [llms.txt](https://docs.coherence.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherence.io/2.3/getting-started/setup-a-project/prefab-setup.md).

# 2. Prefab setup

{% hint style="info" %}
If you prefer a video tutorial, refer to [Part 2](https://youtu.be/kyUSiBpZ2Bc?t=63) of our Getting Started series.
{% endhint %}

To start networking a Prefab, simply select a Prefab or GameObject you wish to network, and on the Inspector window, click **Sync with coherence**. In this case, we've created a basic cube.

<figure><img src="/files/LMAByF3fcfrEhVpgOTTe" alt=""><figcaption></figcaption></figure>

This adds a CoherenceSync component to that Prefab, which is all it takes to acknowledge it in the network.

{% hint style="success" %}
Any Prefab that has the CoherenceSync component on it is known as a Networked Prefab. You can inspect which Networked Prefabs you have currently in your project via top menu `coherence > Networked Prefabs`.
{% endhint %}

Next, we want to select which variables to network.

Open the Configure window, accessible from within the CoherenceSync Inspector.

<figure><img src="/files/NEQCHuzkfcB4rg8WfONi" alt=""><figcaption></figcaption></figure>

From within the Configure window, you can toggle the variables you care about being networked.

You can toggle any variable available in this window, including custom scripts attached to the GameObject and any of its children. To network variables on children, refer to [Syncing child GameObjects](/2.3/manual/networking-state-changes/child-gameobjects.md).

Let's toggle `rotation` and `localScale` in the `Transform` component, so that we network all three properties.

If you move into the `Methods` tab, you can toggle methods to create [Network Commands](/2.3/manual/networking-state-changes/commands.md).

For now we're not going to be using commands, so we can leave this window untouched.

Next up is the `Components` tab. On this windows you decide how your components should behave, based on [authority](/2.3/manual/networking-state-changes/authority.md) — this is useful to quickly turn logic on/off depending on who is simulating the GameObject currently.

{% hint style="info" %}
The Components tab of the Configure window offers a quick way to react to network state changes. However, for advanced scenarios where you want to have full control over what happens, you hook into the numerous UnityEvents that CoherenceSync exposes, both through UI or through code.
{% endhint %}

Let's make our cube change color based on who owns it. To do so, we select `Handle Material` in the `Mesh Renderer` component.

<figure><img src="/files/vUDpCXTzu3ZUEv9atUuC" alt=""><figcaption></figcaption></figure>

Now, let's create two materials. We'll use green for authority and red for remote.

<figure><img src="/files/mKhMoOmywAwOo7jZN8AQ" alt=""><figcaption><p>New Authority.mat material, using a bright green color</p></figcaption></figure>

<figure><img src="/files/g3Qkzpz8AfEIKqfJVQVy" alt=""><figcaption><p>Reference the materials</p></figcaption></figure>

### Commiting the changes

When Networked Prefabs are added or removed, or the variables to network within them change, you will need to **bake** to commit the changes. coherence informs you about the need to bake in different ways (check out [Baking](/2.3/manual/baking-and-code-generation.md) section), but for the time being, let's focus on one of them — the bake button on the Project Window:

<figure><img src="/files/D6EOsJhiHqFhOg2BlsPD" alt=""><figcaption><p>The Project Window warns when baking is required.</p></figcaption></figure>

That warning icon tells you there's changes made on Networked Prefabs that require to bake. Simply click the button to perform a bake operation.

From now on, every change we do and want to commit to, we'll need to bake i.e., press this button.

{% hint style="success" %}
Refer to [Baking](/2.3/manual/baking-and-code-generation.md) for an in-depth exploration of what baking does and why it's essential.
{% endhint %}

### What we have so far

At this point, we have:

* A blank scene (with default Camera and Directional Light)
* To that scene, we've added a CoherenceBridge, a CoherenceLiveQuery and a Connection Dialog Prefab that will handle the connection logic
* A Cube that we converted into a Networked Prefab.
  * We're syncing Transform's position, rotation and scale.
  * We're changing Mesh Renderer material based on authority.
* Baked!

We're now ready to test what we have. **No, so far we've written no logic**. Next, we'll be using the Unity Editor in Play Mode to illustrate how networking happens.

***

{% hint style="success" %}
**To recap**

This is it! Setting up an object to be networked doesn't require additional steps:

* A Prefab with a `CoherenceSync` on it
* Configuring what to sync in the **Configure** window
* Baking

Now let's run this setup [**locally**](/2.3/getting-started/setup-a-project/local-development.md) or using the [**coherence cloud**](/2.3/hosting/coherence-cloud.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherence.io/2.3/getting-started/setup-a-project/prefab-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
