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:
- Create a Unity account.
- Learn about pricing and billing.
Games using the Unity Engine
To get started using UGS with your Unity project:
- Create a new Unity Cloud project.
- For new projects, Create a project in the Unity Hub. This automatically creates your project in the Unity Cloud Dashboard.
- For existing Unity projects:
- Create a project in the Unity Cloud Dashboard.
- Link your project to a Unity Editor project.
- Install the UGS packages you need.
- Import the namespace for your SDK.
- Initialize UGS in your game code.
- 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:
- Create a project in the Unity Cloud Dashboard.
- 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:
- The Unity Gaming Services SDK for the Unreal Engine to implement:
- The Vivox Unreal SDK
Create a project in the Unity Hub
The fastest way to create a new Unity Cloud connected project is via the Unity Hub.
- In the Unity Hub, select New project.
- Enter the required fields, including your Unity Organization.
- 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:
- Select Projects from the primary navigation menu.
- Select New in the upper-right of the Projects page.
- Enter a project name and COPPA designation.
- 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:
- Select Edit > Project Settings > Services.
- Select Use an existing Unity project ID.
- Select an Organization and a project from the drop-down menus.
- 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:
- In the Unity Editor, select Window > Package Manager.
- In the Package Manager, select the Unity Registry list view.
- Search for the package name, or locate it in the registry list.
- 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
- Refer to Unity’s Use Cases sample project for inspiration on how you can use UGS features.
- Implement individual services.
- Use the UGS CLI or Deployment window to simplify configuration management workflows.