Build a Live Game With Unity Gaming Services
UGS Packages
| Package | Min Version | Purpose |
|---|---|---|
com.unity.services.core | 1.16.0 | Initialization, dependency graph |
com.unity.services.authentication | 3.6.1 | Player sign-in and identity |
com.unity.services.cloudcode | 2.10.3 | Server-authoritative C# modules |
com.unity.services.cloudsave | 3.4.0 | Per-player and shared key-value storage |
com.unity.remote-config | 4.2.5 | Server-side game configuration |
com.unity.services.deployment | 1.7.2 | Deploy cloud resources from Editor |
com.unity.services.tooling | 1.4.1 | Access Control and Game Overrides |
com.unity.services.apis | 1.1.1 | Generated REST clients for all UGS services |
- Initialization Pattern
- Package Map
- Architecture — How Packages Combine
- Core Services — Quick Reference
- Asset Store Building Blocks
- Ready-Made Feature Blueprints
- Common Architecture Patterns
- Validation
- Deployment Checklist
- Detailed References
Initialization Pattern
Every UGS game starts the same way. com.unity.services.core must initialize first, then the player signs in:
using Unity.Services.Core;
using Unity.Services.Authentication;
await UnityServices.InitializeAsync();
await AuthenticationService.Instance.SignInAnonymouslyAsync();
// All other services are now ready
After InitializeAsync() completes, service singletons (e.g. CloudSaveService.Instance, CloudCodeService.Instance) are available.
Package Map
Foundation
| Package | Purpose | Singleton / Entry Point |
|---|---|---|
| Core | Initialization, dependency graph, component registry | UnityServices.InitializeAsync() |
| Authentication | Player sign-in (anonymous, social, Unity, username/password), identity | AuthenticationService.Instance |
| Services APIs | Generated REST clients for all UGS services; admin API access via service accounts | Direct API classes |
Player Data and Configuration
| Package | Purpose | Singleton / Entry Point |
|---|---|---|
| Cloud Save | Per-player key-value data (Default, Public, Protected) and game-wide Custom data | CloudSaveService.Instance.Data.Player / .Data.Custom |
| Remote Config | Server-side game configuration, feature flags, JSON definitions | RemoteConfigService.Instance |
| Economy | Virtual currencies, inventory items, purchases, stores | EconomyService.Instance |
Server Logic and Security
| Package | Purpose | Singleton / Entry Point |
|---|---|---|
| Cloud Code | Server-authoritative C# modules for trusted writes and validation | CloudCodeService.Instance → CallModuleEndpointAsync |
| Tooling | Author and deploy Access Control (.ac) and Game Overrides (.ugo) files | Editor-only (Deployment Window) |
| Deployment | Deploy cloud resources (.rc, .ac, .ccmr, .lb, etc.) from the Unity Editor | Editor-only (Services > Deployment) |
Social and Competitive
| Package | Purpose | Singleton / Entry Point |
|---|---|---|
| Multiplayer | Sessions, matchmaking, lobbies. Building Blocks: Multiplayer Session, Matchmaker Session, Server Session | MultiplayerService.Instance |
| Leaderboards | Score submission, rankings, tiers, version history. Building Block: Leaderboards | LeaderboardsService.Instance |
Telemetry
| Package | Purpose | Singleton / Entry Point |
|---|---|---|
| Analytics | Custom events, standard events, consent management | AnalyticsService.Instance |
Architecture — How Packages Combine
UnityServices.InitializeAsync()
│
▼
AuthenticationService
(sign in → PlayerId)
│
┌───────────────┼───────────────┐
▼ ▼ ▼
Remote Config Cloud Save Economy
(game config, (player state, (currencies,
definitions, progress, inventory,
feature flags) preferences) purchases)
│ │ │
└───────┬───────┘ │
▼ │
Cloud Code │
(server-authoritative │
writes, validation, ◄─────────┘
anti-cheat logic)
│
┌───────┼───────┐
▼ ▼ ▼
Cloud Save Economy Leaderboards
(Protected (server (score
writes) grants) submission)
Key principle: For any data that affects game integrity (XP, rewards, currency), route writes through Cloud Code modules. Direct client writes are only appropriate for non-sensitive data (preferences, display settings).
Core Services — Quick Reference
Authentication
Package: com.unity.services.authentication (>= 3.6.1)
Handles player identity. Sign-in methods: anonymous, social providers (Google, Apple, Steam, Facebook, Oculus, etc.), Unity browser, username/password, and device code flow.
After sign-in: PlayerId and PlayerName are available. All sign-in methods fire the SignedIn event. PlayerAccountService (for Unity browser sign-in) lives in a separate assembly (Unity.Services.Authentication.PlayerAccounts).
- Full reference: references/authentication.md
- Building Block: Player Account — ready-made sign-in UI and identity management
Cloud Code
Package: com.unity.services.cloudcode (>= 2.10.3)
Runs server-side C# modules (.NET 9) for trusted operations. Modules are deployed as .ccmr files. The client calls:
var result = await CloudCodeService.Instance.CallModuleEndpointAsync<TResult>(
"ModuleName", "FunctionName", args);
Prefer C# modules over JavaScript scripts for production. Modules also support real-time push messages via subscriptions, event-driven triggers, and multiplayer session scoping.
- Full reference: references/cloud-code.md
Cloud Save
Package: com.unity.services.cloudsave (>= 3.4.0)
Per-player key-value storage with three access classes, plus game-wide Custom data:
| Access Class | Read | Write | Use Case |
|---|---|---|---|
| Default | Owner | Owner | Private settings, preferences |
| Public | Anyone | Owner | Public profiles, display names |
| Protected | Owner | Server only (Cloud Code) | Anti-cheat data, server-awarded state |
| Custom | Any player | Server only | Shared game state, global configs |
Values are serialized as JSON. Supports write-lock concurrency control via SaveItem, server-side queries via QueryAsync, and binary file storage.
- Full reference: references/cloud-save.md
- Building Blocks: Used by Achievements (