Key concepts
Understand key concepts to use Unity Gaming Services effectively.
Read time 2 minutesLast updated 17 hours ago
Before you start, take a few minutes to understand some of the key concepts that underpin Unity Gaming Services.
Server-side game systems
For live games, especially multiplayer ones, it’s important to have a single place to manage player data. Rather than each player’s device managing that player’s data, a central server communicating with all player devices handles important game decisions. This can help mitigate cheating tactics that may allow players to gain an unfair advantage, or acquire resources that they would otherwise need to purchase or earn. Similarly, to ensure that live events and competitive features are fair to all players, your game should manage data and decisions in the cloud. Unity Gaming Services lets you:- Keep player data safely in the cloud using the Cloud Save service.
- Run economy and game logic in the cloud using the Economy and Cloud Code services.
Asynchronous code
Like any online service, Unity Gaming Services are all based on asynchronous operations. This means that client requests to a service don’t stop the game to wait for the response. Gameplay, UI, and animations can continue while service requests occur in the background. For this, Unity Gaming Services rely on the Task-based Asynchronous Pattern (TAP), which makes writing asynchronous code in C# relatively easy. If you’re already familiar with writing code in Unity, you probably understand Coroutines, which you can use for asynchronous logic. While Coroutines are still useful for controlling what’s going on in the foreground, async Tasks are better for managing things happening in the background, such as web requests. Throughout the UGS documentation, you will encounter theasyncawaitasyncTaskawaitasyncFor more information, see Microsoft’s conceptual guide on asynchronous programming.async Task RefreshPlayerWallet(){ // Use an animation to show the player something is happening. waitIndicator.gameObject.SetActive(true); // Download this player's currency statuses from UGS; // this asynchronous task won't interrupt the animation. var newWalletData = await EconomyManager.RefreshWalletData(); // Once you have the downloaded data, update your UI. walletView.Refresh(newWalletData); waitIndicator.gameObject.SetActive(false);}
SDK APIs versus REST APIs
There are two ways to access Unity Gaming Services programmatically:- SDK (client) APIs
- REST (web) APIs