Get started with UGS
Learn how to set up Unity Gaming Services in your project.
Read time 4 minutesLast updated 17 hours ago
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 Dashboard.
- For existing Unity projects:
- Create a project in the Unity 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 Dashboard.
- Refer to the REST API getting started documentation.
- 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.
Create a project in the Unity Dashboard
Manage your projects and services from the Unity 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.
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.
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.
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.
To initialize Unity Services in your game code, create a script that imports the Services Core namespace (
Unity.Services.CoreInitializeAsyncThis method initializes all Unity Gaming Services that are installed in your project. You can use theusing System;using Unity.Services.Core;using UnityEngine;public class InitializationExample : MonoBehaviour{ async void Awake() { try { await UnityServices.InitializeAsync(); } catch (Exception e) { Debug.LogException(e); } }}
StateCreate 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.