public Purchasing.ConfigurationBuilder AddProduct (string id, Purchasing.ProductType type);
public Purchasing.ConfigurationBuilder AddProduct (string id, Purchasing.ProductType type, Purchasing.IDs storeIDs);

Parameters

id 独立于商店的 ID。
type 商品类型。
storeIDs 一组特定于商店的标识符(可选),当商品在不同的商店中拥有不同的 ID 时使用。

Returns

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

Description

通过 Unity IAP ID、类型和特定于商店的 ID 组(可选)添加商品。

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


using UnityEngine;
using UnityEngine.Purchasing;

public class MyStoreClass : MonoBehaviour, IStoreListener { void Awake() { ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); builder.AddProduct("levelpackfoo", ProductType.NonConsumable); UnityPurchasing.Initialize(this, builder); }

public void OnInitialized(IStoreController controller, IExtensionProvider extensions) {} public void OnInitializeFailed(InitializationFailureReason error) {} public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) { return PurchaseProcessingResult.Complete; } public void OnPurchaseFailed(Product item, PurchaseFailureReason r) {} }