unity-gaming-services
A guide for implementing Unity's first-party backend services for multiplayer and live-ops.
Install
mkdir -p .claude/skills/unity-gaming-services && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14141" && unzip -o skill.zip -d .claude/skills/unity-gaming-services && rm skill.zipInstalls to .claude/skills/unity-gaming-services
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Complete setup guide for Unity Gaming Services (UGS): Authentication, Lobby, Relay, Leaderboards, Cloud Save. First-party backend for Unity 6 multiplayer and live-ops projects.Key capabilities
- →Set up Unity Gaming Services project
- →Implement Authentication for anonymous and platform login
- →Create and join multiplayer lobbies
- →Manage peer-to-peer NAT traversal with Relay
- →Save and load player data across devices with Cloud Save
How it works
The skill provides a setup guide and implementation steps for various Unity Gaming Services modules by integrating specific Unity packages and code examples.
Inputs & outputs
When to use unity-gaming-services
- →Setting up multiplayer lobbies
- →Implementing relay for game networking
- →Integrating authentication services
- →Configuring cloud-saved player progress
About this skill
Unity Gaming Services (UGS)
Overview
Unity Gaming Services is the first-party backend suite for Unity 6 games. It provides Authentication, Lobby, Relay (NAT traversal), Leaderboards, Cloud Save, and Cloud Code — all integrated into the Unity Dashboard and Package Manager. The recommended backend for new Unity-native multiplayer and live-ops projects.
When to Use
- Use for multiplayer sessions (Lobby + Relay + NGO).
- Use for cloud-saved player progress across devices.
- Use for global leaderboards without a custom server.
- ❌ Do NOT use if your game is fully offline with no cloud features.
Service Map
| Service | Purpose | Required Package |
|---|---|---|
| Authentication | Anonymous + platform login | com.unity.services.authentication |
| Lobby | Room creation & match discovery | com.unity.services.lobby |
| Relay | Peer-to-peer NAT traversal | com.unity.services.relay |
| Leaderboards | Score ranking | com.unity.services.leaderboards |
| Cloud Save | Cross-device persistence | com.unity.services.cloudsave |
Setup Checklist
☐ 1. Create project at dashboard.unity3d.com
☐ 2. Link: Edit → Project Settings → Services → Link
☐ 3. Install packages (Package Manager → Add by name):
com.unity.services.core
com.unity.services.authentication
(+ service-specific packages above)
☐ 4. Implement InitializeAsync() at game boot (see below)
Core Implementation
// --- IUGSAuthService.cs ---
using System.Threading.Tasks;
public interface IUGSAuthService
{
Task InitializeAsync();
Task SignInAnonymouslyAsync();
string PlayerId { get; }
bool IsSignedIn { get; }
}
// --- UGSAuthService.cs ---
using System.Threading.Tasks;
using Unity.Services.Authentication;
using Unity.Services.Core;
using UnityEngine;
public class UGSAuthService : IUGSAuthService
{
public string PlayerId => AuthenticationService.Instance.PlayerId;
public bool IsSignedIn => AuthenticationService.Instance.IsSignedIn;
public async Task InitializeAsync()
{
if (UnityServices.State == ServicesInitializationState.Initialized) return;
await UnityServices.InitializeAsync();
}
public async Task SignInAnonymouslyAsync()
{
if (IsSignedIn) return;
try { await AuthenticationService.Instance.SignInAnonymouslyAsync(); }
catch (AuthenticationException ex) { Debug.LogError($"[UGS] Auth failed: {ex.Message}"); throw; }
}
}
Lobby: Create & Join
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.Services.Lobbies;
using Unity.Services.Lobbies.Models;
public class UGSLobbyService
{
private Lobby _currentLobby;
public async Task<Lobby> CreateLobbyAsync(string name, int maxPlayers)
{
var options = new CreateLobbyOptions { IsPrivate = false };
_currentLobby = await LobbyService.Instance.CreateLobbyAsync(name, maxPlayers, options);
return _currentLobby;
}
public async Task<Lobby> JoinByCodeAsync(string code) =>
_currentLobby = await LobbyService.Instance.JoinLobbyByCodeAsync(code);
// Call every 15s from host to prevent lobby expiry
public async Task HeartbeatAsync()
{
if (_currentLobby != null)
await LobbyService.Instance.SendHeartbeatPingAsync(_currentLobby.Id);
}
}
Cloud Save: Player Data
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.Services.CloudSave;
public class UGSCloudSaveService
{
public async Task SaveAsync<T>(string key, T data)
{
await CloudSaveService.Instance.Data.Player.SaveAsync(
new Dictionary<string, object> { { key, data } });
}
public async Task<T> LoadAsync<T>(string key, T defaultValue = default)
{
var result = await CloudSaveService.Instance.Data.Player
.LoadAsync(new HashSet<string> { key });
return result.TryGetValue(key, out var item) ? item.Value.GetAs<T>() : defaultValue;
}
}
TDD Contract
public class MockUGSAuthService : IUGSAuthService
{
public string PlayerId => "mock-player-id";
public bool IsSignedIn => true;
public Task InitializeAsync() => Task.CompletedTask;
public Task SignInAnonymouslyAsync() => Task.CompletedTask;
}
[Test]
public async Task Auth_WhenSignedIn_PlayerIdNotEmpty()
{
var auth = new MockUGSAuthService();
await auth.SignInAnonymouslyAsync();
Assert.IsFalse(string.IsNullOrEmpty(auth.PlayerId));
}
Best Practices
- ✅ Always call
InitializeAsync()+SignInAnonymouslyAsync()before any UGS service. - ✅ Use
IUGSAuthServiceinterface everywhere — easy mock swap for TDD. - ✅ Send Lobby heartbeat every 15s from the host.
- ✅ Prefer Cloud Save over PlayerPrefs for cross-device data.
- ❌ NEVER call UGS APIs before initialization completes.
- ❌ NEVER submit competitive scores client-side without Cloud Code validation.
Related Skills
@multiplayer-netcode— NGO + Relay for the transport layer@playfab-economy-v2— Alternative backend for economy and virtual currency@repository-pattern— Wrap Cloud Save behindIRepository<T>@service-locator-pattern— RegisterIUGSAuthServiceat bootstrap
When not to use it
- →If the game is fully offline with no cloud features
Prerequisites
Limitations
- →Do NOT use if your game is fully offline with no cloud features.
- →NEVER call UGS APIs before initialization completes.
- →NEVER submit competitive scores client-side without Cloud Code validation.
How it compares
This skill offers a structured, integrated approach to setting up Unity's first-party backend services, unlike manually configuring disparate backend solutions.
Compared to similar skills
unity-gaming-services side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| unity-gaming-services (this skill) | 0 | 5mo | No flags | Intermediate |
| fastapi-templates | 520 | 2mo | No flags | Intermediate |
| android-kotlin-development | 268 | 5mo | Review | Advanced |
| fastapi-pro | 79 | 4mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by nlelouche
View all by nlelouche →You might also like
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
android-kotlin-development
aj-geddes
Develop native Android apps with Kotlin. Covers MVVM with Jetpack, Compose for modern UI, Retrofit for API calls, Room for local storage, and navigation architecture.
fastapi-pro
sickn33
Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2. Master microservices, WebSockets, and modern Python async patterns. Use PROACTIVELY for FastAPI development, async optimization, or API architecture.
telegram-bot-builder
davila7
Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.
telegram-mini-app
davila7
Expert in building Telegram Mini Apps (TWA) - web apps that run inside Telegram with native-like experience. Covers the TON ecosystem, Telegram Web App API, payments, user authentication, and building viral mini apps that monetize. Use when: telegram mini app, TWA, telegram web app, TON app, mini app.
stripe-integration
wshobson
Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.