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. Initialize UGS in your game code.
  4. 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.

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:

Copy
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, or take a look at the individual services UGS has to offer.