Get started with Friends
Attention: The Digital Services Act (DSA) requires Unity to notify our customers’ end users if Unity takes an action that impacts those end users under the DSA. To comply with this requirement, if you use Unity Gaming Services (UGS) products that rely on the Unity Authentication Service, you must integrate the notification API.
For more information on DSA, refer to the Digital Services Act - compliance update.
To make your game compliant, refer to DSA notifications.
This guide walks you through how to set up and start using Friends.
Prerequisites
To get started with Friends, you need to do the following:
Set up Friends
You can set up and manage Friends through the Unity Cloud Dashboard:
- Go to cloud.unity.com.
- Select the Products tab from the sidebar.
- Under Gaming Services > Community, go to Friends and select Launch.
When you launch Friends for the first time, this adds Friends to the Shortcuts section on the sidebar and opens the Overview page.
Link your project with the Unity Cloud Dashboard
You must link your project with the Unity Cloud Dashboard to use the Friends service.
- From the Unity Editor, select Edit > Project Settings... > Services.
- Link your project.
- If your project doesn't have a Unity project ID:
- Select Create a Unity Project ID > Organizations, then select an organization.
- Select Create project ID.
- If you have an existing Unity project ID to use:
- Select Use an existing Unity project ID.
- Select an organization and a project.
- Select Link project ID.
- If your project doesn't have a Unity project ID:
Your Unity Project ID now appears in Unity Editor, and the project is linked to Unity’s cloud services. You can also access your Unity Project ID in code using UnityEditor.CloudProjectSettings.projectId
.
Enable the Friends service
You can enable the Friends service for your project from the Unity Cloud Dashboard.
- Sign in to the Unity Cloud Dashboard.
- Select your project.
- Navigate to Products > Friends.
- You can enable Friends from the Overview page or the Setup Guide.
The Setup Guide walks you through linking your Unity project, installing the Friends package, and enabling the Friends service.
Install the Friends package
Once you've linked your project to the Unity Cloud Dashboard, you can install the latest version of the Friends package.
Use the Unity Package Manager to import the Friends package in the Unity Editor.
Initialize the Friends service
Once you’ve enabled the Friends service and imported the Friends SDK through the Package Manager in the Unity Editor, initialize the Core SDK using await UnityServices.InitializeAsync()
.
The following code sample shows how to initialize the Friends service and any other Unity services in your project.
// Import required packages
using Unity.Services.Core;
using Unity.Services.Authentication;
...
private async Task MyMethod()
{
// Initialize all of the used services
await UnityServices.InitializeAsync();
// Sign in anonymously or using a provider
await AuthenticationService.Instance.SignInAnonymouslyAsync();
// Initialize friends service
await FriendsService.Instance.InitializeAsync();
// Start using the Friends SDK functionalities.
var friends = FriendsService.Instance.Friends;
}