Get started with UGS

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:

Games using the Unity Engine

To get started using UGS with your Unity project:

  1. Create a new Unity Cloud project.
  2. Install the UGS packages you need.
  3. Import the namespace for your SDK.
  4. Initialize UGS in your game code.
  5. Create 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 in the Unity Cloud Dashboard.
  2. Refer to the REST API getting started documentation.

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

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 Cloud Dashboard and you don't need to connect them manually.

You can already begin browsing services in the Unity Cloud Dashboard. To integrate the services, proceed to Install UGS packages.

Create a project in the Unity Cloud Dashboard

Manage your projects and services from the Unity Cloud Dashboard. 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 designation.
  4. Select Create.

You can now configure your project in the Unity Cloud Dashboard and start to configure some services prior to integration with a Unity Editor project. For example, configure Economy items or create Game Overrides. Next, link your Unity Cloud project to a Unity Editor project.

Learn more about managing Unity projects.

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 to the Unity Cloud 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:

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:

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 method to check the initialization status of your game at runtime. For more information, refer to the Services Core API 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 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