# Get started with UGS

> Learn how to set up Unity Gaming Services in your project.

This topic describes how to set up your project to use Unity Gaming Services.

### Prerequisites

If you haven’t done so already, complete the following before starting the onboarding process:

* [Create a Unity account](/cloud/accounts/create-account.md).
* Learn about [pricing and billing](./pricing-and-billing).

### Games using the Unity Engine

To get started using UGS with your Unity project:

1. Create a new Unity Cloud project.
   * For new projects, [Create a project](#create-a-project-in-the-unity-hub) in the Unity Hub. This automatically creates your project in the Unity Dashboard.
   * For existing Unity projects:
     1. [Create a project](#create-a-project-in-the-unity-dashboard) in the Unity Dashboard.
     2. [Link your project](#link-your-project-in-the-unity-editor) to a Unity Editor project.
2. [Install](#install-ugs-packages) the UGS packages you need.
3. [Import the namespace](#import-sdk-namespace) for your SDK.
4. [Initialize UGS](#initialize-unity-services-in-your-game-code) in your game code.
5. [Create](#create-your-first-cloud-code-script-and-beyond) your first Cloud Code script.

### Games using REST API

If you use a different gaming engine, you can implement UGS in your game using REST APIs. To start using UGS:

1. [Create a project](#create-a-project-in-the-unity-dashboard) in the Unity Dashboard.
2. Refer to the REST API [getting started](https://services.docs.unity.com/docs) documentation.

If you use the Unreal Engine, you can also implement some UGS features in your game, using:

* The [Unity Gaming Services SDK for the Unreal Engine](/matchmaker/ugs-for-the-unreal-engine.md) to implement:
  * [Authentication](/authentication-unreal.md)
  * [Multiplay Hosting](/multiplay-hosting-unreal.md)
  * [Matchmaker](/matchmaker-unreal.md)
* The [Vivox Unreal SDK](https://docs.vivox.com/v5/general/unreal/5_23_0/en-us/Default.htm#Unreal/Unreal.htm)

## Create a project in the Unity Hub

The fastest way to create a new Unity Cloud connected project is via the Unity Hub.

1. In the Unity Hub, select **New project**.
2. Enter the required fields, including your Unity Organization.
3. Ensure the **Connect to Unity Cloud** checkbox is selected.

Your new Unity project is automatically created in the Unity Dashboard and you don't need to connect them manually.

You can already begin browsing services in the Unity Dashboard. To integrate the services, proceed to [Install UGS packages](#install-ugs-packages).

## Create a project in the Unity Dashboard

Manage your projects and services from the [Unity Dashboard](https://cloud.unity.com/). To create a new project:

1. Select **Projects** from the primary navigation menu.
2. Select **New** in the upper-right of the **Projects** page.
3. Enter a project name and [COPPA](https://www.ftc.gov/enforcement/rules/rulemaking-regulatory-reform-proceedings/childrens-online-privacy-protection-rule) designation.
4. Select **Create**.

You can now configure your project in the Unity Dashboard and start to configure some services prior to integration with a Unity Editor project. For example, configure [Economy](/economy.md) items or create [Game Overrides](/game-overrides.md).
Next, [link your Unity Cloud project](#link-your-project-in-the-unity-editor) to a Unity Editor project.

Learn more about [managing Unity projects](/cloud/projects/create-project.md).

## Link your project in the Unity Editor

To use Unity Gaming Services, you must link your project in the Unity Editor to a Unity Cloud project.

To link your project in the Editor:

1. Select **Edit** > **Project Settings** > **Services**.
2. Select **Use an existing Unity project ID**.
3. Select an Organization and a project from the drop-down menus.
4. Select **Link project ID**.

Learn more about [linking projects](/cloud/projects/configure-project-for-unity-cloud.md) to the Unity Dashboard.

## Install UGS packages

Install the corresponding packages for the services you want to implement in your project. To view and install packages applicable to UGS:

1. In the Unity Editor, select **Window** > **Package Manager**.
2. In the Package Manager, select the **Unity Registry** list view.
3. Search for the package name, or locate it in the registry list.
4. Select the package, then click **Install**.

You can also type **services** in the search bar, which returns results for all the services except Remote Config.

In Editor versions 2022.1 or higher, the Package Manager’s **Services** tab displays all packages available for UGS.

## Import SDK namespace

To access the API for an SDK, you must import the SDK's namespace in your script. For example, for Analytics:

```cs
using Unity.Services.Analytics;
```

## Initialize Unity Services in your game code

You must initialize the Services Core SDK before calling any of the services’ functionality. The recommended best practice is to initialize services early in your game’s runtime, preferably at launch.

> **Note:**
>
> You don't need to install the `com.unity.services.core` package or include it in your package manifest. This is pulled automatically when you install a UGS package that depends on it.

To initialize Unity Services in your game code, create a script that imports the Services Core namespace (`Unity.Services.Core`), then call the `InitializeAsync` method. For example:

```cs
using System;
using Unity.Services.Core;
using UnityEngine;

public class InitializationExample : MonoBehaviour
{
	async void Awake()
	{
		try
		{
			await UnityServices.InitializeAsync();
		}
		catch (Exception e)
		{
			Debug.LogException(e);
		}
	}
}
```

This method initializes all Unity Gaming Services that are installed in your project. You can use the [`State`](./services-core-api#state) method to check the initialization status of your game at runtime. For more information, refer to the [Services Core API](./services-core-api#initializeasync) documentation.

## Create your first Cloud Code script and beyond

Custom server-authoritative economy logic or game logic is one of the most common uses for Unity Gaming Services. This [Cloud Code walkthrough](/cloud-code/scripts/getting-started.md#sdkinstallation) includes everything you’ll need to get started, including installation, initialization, dashboard configuration, and remotely executing a simple Cloud Code script from your game client.

## Next steps

* Refer to Unity’s [Use Cases sample project](/services/solutions/use-cases-project.md) for inspiration on how you can use UGS features.
* Implement [individual services](./_index).
* Use the [UGS CLI](https://github.com/Unity-Technologies/unity-gaming-services-cli) or [Deployment window](https://docs.unity3d.com/Packages/com.unity.services.deployment@latest/index.html?subfolder=/manual/deployment_window.html) to simplify configuration management workflows.
