Version: 2019.4
Managing and publishing your game on the UDP console
UDP reference

Using UDP with other services

Using Cloud Build with UDP

You can use Cloud Build to deploy your game to the UDP console in the following ways:

Pushing the build to the UDP console via Cloud Build

This section explains how to use Cloud Build to push your game to UDP. In the Unity Editor, enable Cloud Build through the Unity Services window.

Using Cloud Build in the Editor to deploy your game to UDP

To deploy your game to UDP via the Cloud Build feature in the Unity Editor, you need to upload your UDP build and push it to UDP.

  1. In the Cloud Build Services window, if you haven’t uploaded any build before, select Upload Build.
  2. In FILE:
    • Choose the APK of your UDP build
    • Enter a useful LABEL
    • Set the PLATFORM field to Android.
  3. Select UPLOAD, and let it complete the upload process.
  4. In the Cloud Build Services window, locate the desired build from the build History timeline and select Push to Unity Distribution Portal.
    1. Verify that you want to push, and that the action completes.

Using the Unity Dashboard to deploy your game to UDP

To deploy your game to UDP via the Cloud Build feature in the Unity Dashboard, you need to upload your UDP build to the Unity Dashboard and push it from there to UDP.

  1. In the Unity Developer Dashboard, navigate to your Project’s Cloud Build > History.
  2. Select Upload, then select your APK file.
  3. In the Platform field, select Android.
  4. Select Upload.
  5. Select the More menu next to your build to expand the drop-down menu.
  6. Select Push to Unity Distribution Portal.

Building and deploying via Cloud Build

If you use Unity Teams Advanced, you can generate builds automatically.

In the Cloud Build Services window:

  1. Select Manage Build Targets > Add new build target
  2. In the TARGET SETUP window, set the PLATFORM field to Android and enter a useful TARGET LABEL.
  3. Select Next: Save.
  4. Select Start Cloud Build, then select the target build you just created.

Push your build to UDP directly via the Unity Cloud Build Developer Dashboard (as shown above).

Service interoperability

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.

How does it work?

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.

Locating udp.json

The file udp.json is saved in:

Application.PersistentDataPath + '/Unity' + /Application.CloudProjectID + /udp/udp.json

Where:

  • Application.PersistentDataPath is your game’s persistent data path
  • Application.CloudProjectID is your game’s Unity project ID

Here 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

Reading udp.json

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”:“SamsungGalaxyStore”,“udpClientId”:“icjaB7wmu_q7AOjrSLH8yw”,“cloudProjectId”:“bc2be074–09f3–450f–8e98-a0f79c9746f7”}

In this example, the game was downloaded from the Samsung Galaxy Store.

Tip: use JSONUtility.FromJsonOverwrite to read the contents of the file as a text asset.

udpStore values

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
VIVEPORT Htc
Mi GetApps (Xiaomi) XiaomiStore
Mi Game Center (Xiaomi China) XiaomiStoreCn
HUAWEI AppGallery Huawei
Samsung Galaxy Store SamsungGalaxyStore
QooApp Game Store QooApp
TPAY MOBILE Stores Tpay
Uptodown Uptodown
SHAREit ShareIt
JioGames JioGamesStore

Using udpStore with Remote Config

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.

  1. Download and install the UDP package.
  2. Download and install the Unity Remote Config package. See the Remote Config documentation.
  3. Create an AppAttributes struct, which at least has a parameter, “udpStore”:
    public struct AppAttributes { public string udpStore; }
  4. In the game code, implement the Remote Config ConfigManager.FetchConfigs call.
  5. When calling FetchConfigs, create a new instance of the AppAttributes struct, read the UDP store data file from: Application.PersistentDataPath + ‘/Unity’ + /Application.CloudProjectId + /udp/udp.json Use JSONUtility.FromJsonOverwrite to read the contents of the file as a text asset.
    { 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); }
  6. Ensure the AppAttributes struct is used in ConfigManager.FetchConfigs.
  7. Open the Remote Config window (Window > Remote Config), and create the parameters that you’d want to change based on the UDP store.
  8. When the parameters are set up, and instrumented in the game code, create a rule for each store in the Remote Config window.
  9. In each rule’s condition, put: app.udpStore == “[storeName]”
  10. To enable the setting, select the checkbox next to the name of the rule on the left panel in the Remote Config window.
  11. Build the app to a device and ensure the rules are properly applied, and ship it.

Implementing IAP items for UDP with Unity IAP

If you want to implement UDP using Unity IAP, 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:

  • Initializing UDP
  • Querying the store’s IAP product inventory
  • Requesting to purchase a product
  • Consuming the purchased item

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.

Querying IAP inventory

With Unity IAP (code implementation)

Fetching IAP products defined in the Editor

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 (Window > 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);
   }
}
Fetching IAP product information from the UDP console

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.

Fetching the IAP Catalog from the UDP console

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.

Filling in the IAP Catalog with the Unity IAP package

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.

  1. In the Unity Editor, select Window > Unity IAP > IAP Catalog.
  2. Select Add Product and enter the details for each IAP product.
    1. Add the price for the IAP item under Unity Distribution Portal Configuration.
  3. To save your IAP product to the UDP console, select Sync to UDP. Do this for each IAP product you create.

To make sure the IAP Catalog is properly saved, check that the items you added are displayed in the UDP console.

Managing and publishing your game on the UDP console
UDP reference