Get started with UGS

The following describes how to quickly set up your project to use Unity Gaming Services.

Games using the Unity engine

  1. Create a project in the Unity dashboard.
  2. Link your dashboard project to a Unity Editor project.
  3. Install the UGS packages you need.
  4. Initialize UGS in your game code.
  5. Create your first Cloud Code script.

Games using REST API

  1. Create a project in the Unity dashboard.
  2. Refer to the REST API getting started documentation.

Prerequisites

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

  1. Create a Unity ID.
  2. Sign up for Unity Gaming Services.

Create a project in the Unity dashboard

Manage your projects and services from the Unity Dashboard. To create a new project:

  1. Select Projects from the primary navigation menu.
  2. Click Create project in the upper-right of the Projects page.
  3. Enter a project name and COPPA designation.
  4. Click Create project.

For more information, see the documentation on managing Unity projects.

Link your project in the Unity Editor

To use Unity Gaming Services, you must link your project in the Unity Editor with its corresponding entity in the Unity Dashboard.

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.

For more information, see the documentation on linking projects 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.

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

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.

Initialize Unity Services in your game code

You must initialize the Services Core SDK before calling any of the services’ functionality. Unity recommends initializing services early in your game’s runtime, preferably at launch.

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 currently installed in your project. You can use the State method to check the initialization status of your game at runtime. For more information, see 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

Congratulations on implementing your first service. Where you go from here is up to you! Check out Unity’s Use Cases sample project for inspiration, take a look at the individual services UGS has to offer, and get started with the UGS CLI to manage, test and deploy UGS configuration.