NOTE |
---|
Unity Distribution Portal is obsolete. |
Implementing Google Play games services in your Android games lets you leverage Google’s service layer for features such as achievements and leaderboards. If your game implements Google Play game services, additional configuration is required to support the builds that UDP creates for different stores.
When your game invokes Google Play games services, Google Play games services checks that the following details match the information registered on the Google Play Console:
If they don’t match, the player can’t log into the application with Google Play games services.
For certain stores that you publish your game to via UDP, UDP adds a store-specific suffix to the package name. Additionally, if you don’t use your own private key to generate the certificate, UDP generates a certificate for each repacked build. These events would cause your certificate and/or package name to no longer match the information on the Google Play Console. This would prevent users from logging into the game with Google Play game services.
The following section explains how to resolve this issue.
This section explains how to link your UDP versions to a Google Play application so that Google Play game services can work on all of them.
This section explains how to create a Google Play games services project and link it to a new or existing cloud project.
If you selected Yes, my game already uses Google APIs in the Play Games Services setup page:
If you selected No, my game doesn’t use Google APIs in the Play Games Services setup page:
When you create a new Play Games Services project, the Add credential link is disabled.
When you’ve completed the above steps, your Google Play game is linked to its Google Play games services. The next step is to link your UDP builds to the games services.
When you have linked your app to Google Play games services you can link the other (UDP) apps to the games services.
openssl x509 -in [downloaded-pem-filepath] -fingerprint -noout
You can view the UDP builds you’ve linked to your Google Play application in the Google Cloud Platform > Google API & Services dashboard, under Credentials.
These steps enable Google Play games services to work successfully on all the UDP store versions that are linked that way, excluding Mi GetApps (whose SDK integrates an old version of Google Mobile Services, which creates conflicts).
Note: Any changes to Google’s systems could impact the solution described above. For more information on Google’s troubleshooting information, see the Google documentation.
You can use Build AutomationA continuous integration service for Unity projects that automates the process of creating builds on Unity’s servers. More info
See in Glossary to deploy your game to the UDP console in the following ways:
This section explains how to use Build Automation to push your game to UDP.
In the Unity Editor, enable Build Automation in the Project SettingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your project behave. More info
See in Glossary window.
To deploy your game to UDP via the Build Automation feature in the Unity Editor, you need to upload your UDP build and push it to UDP.
To deploy your game to UDP via the Build Automation feature in the Unity Dashboard, you need to upload your UDP build to the Unity Dashboard and push it from there to UDP.
If you use Unity Teams Advanced, you can generate builds automatically.
In the Build Automation tab of the Project Settings window:
Push your build to UDP directly via the Unity Build Automation Developer Dashboard (as shown above).
UDP can tell other services used by your game which store was the game downloaded from.
This information can be used in many ways, by Unity services as well as by third-party or your own services.
For example, Unity Remote Config lets you tune your game settings based on rules that you define, such as which store the game was downloaded from.
This section explains how to let other services gain access to this information, and includes an example.
When your game first launches on a player’s device, UDP creates and drops the udp.json
file in the game’s Persistent Data Path. This file contains the field udpStore
, which shows which store the game was downloaded from. Retrieve that information to use it the way you intend to.
Note: This doesn’t add any new permission into your game manifest.
The file udp.json
is saved in:
Application.PersistentDataPath + '/Unity' + /Application.CloudProjectID + /udp/udp.json
Where:
Application.PersistentDataPath
is your game’s persistent data pathApplication.CloudProjectID
is your game’s Unity project IDHere is an example of a path to the udp.json
file:
path/storage/emulated/0/Android/data/com.mystudio.mygame/files/Unity/c83d2de2-de74-4b75-83fc-ade948bda064/udp/udp.json
Where:
Application.PersistentDataPath
= path/storage/emulated/0/Android/data/com.mystudio.mygame
Application.CloudProjectID
= c83d2de2-de74-4b75-83fc-ade948bda064
The file udp.json
contains the following information:
{"key":"UDP","udpStore":"StoreName","udpClientId":"value_of_udpClientId","CloudProjectId":"value_of_CloudProjectId"}
The field udpStore
contains the value of the UDP store your game was downloaded from.
Here is an example of a udp.json
file:
{"key":"UDP","udpStore":"Huawei","udpClientId":"icjaB7wmu_q7AOjrSLH8yw","cloudProjectId":"bc2be074-09f3-450f-8e98-a0f79c9746f7"}
In this example, the game was downloaded from the HUAWEI AppGallery.
Tip: use JSONUtility.FromJsonOverwrite
to read the contents of the file as a text asset.
The table below lists the udpStore
values you can expect for stores available on UDP.
These are case-sensitive.
Store (channel name on UDP) | Value for udpStore |
---|---|
UDP Sandbox (for the generic UDP builds) | UdpSandbox |
ONE store | OneStore |
APPTUTTi | Apptutti |
Mi GetApps (Xiaomi) | XiaomiStore |
HUAWEI AppGallery | Huawei |
QooApp Game Store | QooApp |
Uptodown | Uptodown |
SHAREit | ShareIt |
JioGames | JioGames |
Legion Store | Legion |
Unity Remote Config lets you tune your game settings without deploying new versions of your application. When a player launches your game, Remote Config detects contextual attributes used as Rule conditions (based on Unity, the application, the user, or custom criteria that you define). The service then returns customized settings for each player according to the Rules that apply to them.
Use udpStore
as an attribute in your Rule conditions, so you can determine game settings that depend on which UDP store the game was downloaded from.
To implement udpStore with Remote Config, follow these steps.
public struct AppAttributes
{
public string udpStore;
}
{
string udpFilePath = System.IO.Path.Combine(Application.persistentDataPath, "Unity", Application.cloudProjectId, "udp", "udp.json");
string udpFileContents = System.IO.File.ReadAllText(udpFilePath);
var appAttr = JsonUtility.FromJson<AppAttributes>(udpFileContents);
Unity.RemoteConfig.ConfigManager.FetchCompleted += ConfigManager_FetchCompleted;
Unity.RemoteConfig.ConfigManager.FetchConfigs(null, appAttr);
}
If you want to implement UDP using Unity IAPAbbreviation of Unity In App Purchase
See in Glossary, first set up Unity IAP.
Note: If you choose to implement UDP with Unity IAP version 1.22.0–1.23.5 (instead of using the UDP package) then implement via Unity IAP only.
Unity IAP automatically handles the following:
However, your game must properly use Unity IAP’s similar functions (such as initialization and purchase) according to the Unity IAP Documentation.
When you’ve implemented your game’s in-app purchases with Unity IAP, take the following steps to set up UDP with Unity IAP.
When fetching the IAP products to pass to the queryInventory
method, invoke ProductCatalog.LoadDefaultCatalog()
. This returns the IAP products defined in the Editor’s IAP Catalog (Services > Unity IAP > IAP Catalog).
For instance:
var catalog = ProductCatalog.LoadDefaultCatalog();
foreach (var product in catalog.allValidProducts)
{
if (product.allStoreIDs.Count > 0)
{
var ids = new IDs();
foreach (var storeID in product.allStoreIDs)
{
ids.Add(storeID.id, storeID.store);
}
builder.AddProduct(product.id, product.type, ids);
}
else
{
builder.AddProduct(product.id, product.type);
}
}
If you plan to modify your game’s IAP Catalog on the UDP Console, prepare your game to fetch IAP product information from the UDP Console.
When fetching the IAP products to pass to the queryInventory
method, invoke builder.AddProduct to retrieve specific IAP products defined from the UDP console:
builder.AddProduct(product.id, product.type, new IDs{})
To display the product price, formatted with currency, use productInfo.Value.Price
.
To retrieve all the IAP products defined on the UDP Console, don’t invoke any IAP product retrieval method. Your game will then fetch the entire IAP Catalog from the UDP Console.
Note: Uploading a CSV file of IAP products on the UDP Console entirely overwrites your IAP Catalog.
Add and configure your IAP Catalog all your in-app purchases for UDP.
Note: If you don’t use an IAP Catalog in your game client (for instance, you maintain your IAP items solely on your game server) you must still create your IAP Catalog on the UDP console.
To make sure the IAP Catalog is properly saved, check that the items you added are displayed in the UDP console.