Deploying resources with Unity Editor

The Economy Authoring module (installed with the Economy package) allows you to optionally author and modify resources directly within the Unity Editor. You can then upload resources from the Unity Editor to the Dashboard by using the Deployment package.

Economy resources existing in the Unity Editor allow users to treat their source control as the single source of truth (instead of the version in the cloud), simplifying actions such as rollbacks, bisection, and other common operations.

Prerequisites

To use Economy in the Unity Editor, you must first install the com.unity.services.economy SDK and link your Unity Gaming Services project to the Unity Editor.

Link your Unity Gaming Services project with the Unity Editor. You can find your UGS project ID in the Unity Cloud Dashboard.

  1. In Unity Editor, select Edit > Project Settings > Services.

  2. Link your project.

    • If your project doesn't have a Unity project ID:

      1. Select Create a Unity Project ID > Organizations, then select an organization from the dropdown menu.
      2. Select Create project ID.
    • If you have an existing Unity project ID:

      1. Select Use an existing Unity project ID.
      2. Select an organization and a project from the dropdown menus.
      3. Select Link project ID.

Your Unity Project ID appears, and the project is now linked to Unity services. You can also access your project ID in a Unity Editor script using UnityEditor.CloudProjectSettings.projectId.

Install required packages

To create Economy resources within the Editor, you must install the following packages:

  • Deployment
  • Economy (com.unity.services.economy@3.2.1 or greater)

See Unity - Manual: Package Manager window to familiarize yourself with the Unity Package Manager interface.

To install these packages and add them to your list of available packages:

  1. From the Unity Editor’s Package Manager window, select + (add) > Add package by name….
  2. Enter com.unity.services.deployment.
  3. Select Add.
  4. Repeat these steps for com.unity.services.economy.

Authoring within Unity Editor

The Economy Authoring module allows you to create, edit, and deploy Economy resources directly within the Unity Editor.

Create a resource

Follow these steps to create an Economy resource using the Economy Authoring module:

  1. In the Unity Editor, right-click in the Project window, then select Create > Economy File.
  2. Choose and click on the desired resource file type to create between Currency, Inventory Item, Virtual Purchase and Real Money Purchase.
  3. Give the resource file a name.
  4. Press Enter.

The new resource is now visible in the Project window, and in the Deployment window, accessible by selecting Services > Deployment.

Edit a resource

There is currently one method to edit an existing Economy resource:

  • In the Project tab, double-click the existing resource, then choose any text editor to edit the file.

Resource file content

The deployment window finds resources and assigns their type according to their file extension.

Valid file extensions are .ecc (Currency), .eci (Inventory Item), .ecv (Virtual Purchase) and .ecr (Real Money Purchase).

An Economy resource file contains json describing the resource to be deployed.

The json content must match with the extension (type of the resource).

Example for my_currency.ecc:

{
  "name": "MY_CURRENCY",
  "initial": 1,
  "max": 50
}

Example for my_inventory_item.eci:

{
  "name": "MY_ITEM"
}

Example for my_virtual_purchase.ecv:

{
  "name": "VIRTUAL_PURCHASE",
  "costs": [
    {
      "resourceId": "MY_RESOURCE_ID",
      "amount": 2
    }
  ],
  "rewards": [
    {
      "resourceId": "MY_RESOURCE_ID_2",
      "amount": 6,
      "defaultInstanceData": null
    }
  ]
}

Example for my_real_money_purchase.ecr:

{
  "name": "MY_REAL_MONEY_PURCHASE",
  "storeIdentifiers":
    {
      "appleAppStore": "my_id",
      "googlePlayStore": "my_id"
    },
  "rewards": [
    {
      "resourceId": "MY_RESOURCE_ID",
      "amount": 6,
      "defaultInstanceData": null
    }
  ]
}

You can find out which fields should be in your json by looking at the schema for each resource type here.

Some fields may be omitted, such as id and customData. In the event where id is omitted, the resource will use name as id, therefore name will have to follow the naming rules of id as defined in the schema.

Deploy a resource

You can deploy an Economy resource through the Deployment window. See the Deployment package manual for more information.

Some Economy resources have dependencies on other resources, such as Virtual Purchase resources having dependencies on Currency or Inventory Item resources.

When deploying, the Currency and Inventory Item resources are always deployed first.

When deploying Virtual Purchase or Real Money Purchase resources, make sure that the resources used for rewards and costs are also getting deployed at the same time, or already exist.

Deployment window

The Deployment window is a core feature of the Deployment package. It allows all services to have a single cohesive interface for deployment needs, and allows you to upload cloud assets to their respective cloud services.

See the Deployment package manual for more information.