Version: 2017.1
public Purchasing.ConfigurationBuilder AddProducts (IEnumerable<ProductDefinition> products);

参数

products 要添加的商品。

返回

ConfigurationBuilder 引用的实例。适用于链接。

描述

添加 ProductDefinitions 集合。

假设特定于商店的 ID 在各平台上相同;提供不带有商店名称的配置机制。

下面是将多件商品添加到商店类的示例。

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using UnityEngine;
using UnityEngine.Purchasing;

public class MyStoreConfiguration { public static ConfigurationBuilder CreateBuilder() { ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); HashSet<ProductDefinition> productSet = new HashSet<ProductDefinition>() { new ProductDefinition("virtualcurrency_100", "com.unity3d.purchasing.virtualcurrency_100", ProductType.Consumable), new ProductDefinition("levelpackfoo", "com.unity3d.purchasing.levelpackfoo", ProductType.NonConsumable), }; ReadOnlyCollection<ProductDefinition> productCollection = new ReadOnlyCollection<ProductDefinition>(productSet.ToList()); builder.AddProducts(productCollection); return builder; } }