# Samples

The **coherence** package comes with several samples you can choose to add to your project. Each provides Prefabs and scripts that you can add to your Scene and edit however you want.

There are currently 3 samples available: a [Room connection dialog](#room-connect-dialog), a [World connection dialog](#world-connect-dialog), and Lobby connection dialog.

The difference between Rooms and Worlds is explained on this page: [Rooms and Worlds](/1.0/overview/rooms-and-worlds.md). You can also read more about [Lobbies](/1.0/coherence-cloud/lobbies.md).

## Adding a dialog to the scene

Each sample comes with a Prefab that can be added to the Scene. You can add them through *coherence > Explore Samples*.

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

Effectively these do two things for you :&#x20;

1. Import the sample in the Samples directory of your project, if it isn't already.<br>

   <figure><img src="/files/igpxdr8DALPHmIwdnOF4" alt=""><figcaption><p>Adding the Room Connect Dialog creates a copy in your project</p></figcaption></figure>
2. Add the Prefab from the sample to your Scene.\
   From the example above, that would be `Room Connection Dialog.prefab`.

## Room connect dialog

The *Rooms Connect Dialog* has a few helpful components that are explained below.

<figure><img src="/files/lL3Kr8suD9wqEmgB6tNZ" alt=""><figcaption><p>The Room connection dialog</p></figcaption></figure>

* At the top of the dialog we have an **input field for the player's name**.
* Next is a **toggle between Cloud and Local**.\
  You can switch to Local if you want to connect to a Rooms Server that is running on your computer.
* Next is a **dropdown for region selection**. This dropdown is populated when regions are fetched from the coherence cloud. The default selection is the first available region.\
  This is not enabled when you switch from Cloud to Local. This is also only relevant if you deploy your game to several different regions.
* Next is a **dropdown of available Rooms** in the selected region (or in your local server if using the Local mode).
* After selecting a Room from the list the ***Join*** button can be used to join that Room.
* If you know someone has created a room but you don't see it, you can manually refresh the rooms list using the ***Refresh*** button.

### Creating a room

The *Create a room* section adds a Room to the selected region.

<figure><img src="/files/1l9s5u4AlSVHiJgbEv2X" alt=""><figcaption><p>Create room section of the Room connect dialog</p></figcaption></figure>

This section contains controls for setting a **Room's name** and **maximum player capacity**. Pressing the ***Create*** button will create a Room with the specified parameters and immediately add it to the *Room Dropdown* above. ***Create and Join*** will create the Room, and also join it immediately.

## World connect dialog

The *Worlds Connect Dialog* is much simpler. It simply holds a **dropdown for region selection**, an input field for the **players name**, and a ***Connect*** button.

<figure><img src="/files/CRpPnnBNS5tmzEnyx5QI" alt=""><figcaption><p>The Worlds connect dialog</p></figcaption></figure>

If you start a local World server, it will appear as `LocalWorld`.

## Modifying a sample

Samples are copied to your project, this means you can change and customize the scripts and Prefabs however you like.

## Upgrading samples

Future versions of **coherence** won't override your changes. If you upgrade to a newer version of **coherence** and import a new sample, they will be imported in a separate folder named after the **coherence** version.

{% hint style="warning" %}
If you notice that the samples are non-responsive to input, make sure you have an EventSystem component in the scene.
{% endhint %}


---

# Agent Instructions: 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/1.0/get-started/scene-setup/samples.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.
