Version: 5.4 (switch to 5.5b)
言語English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Product

class in UnityEngine.Purchasing

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

マニュアルに切り替える

Description

Product クラスは、IAP で購入されるプロダクトを表します。

以下は、Store クラスでのプロダクトへの参照の利用例です。

no example available in JavaScript
using System;
using UnityEngine;
using UnityEngine.Purchasing;

public class MyStoreClass : MonoBehaviour, IStoreListener { static string kProductID100Currency = "virtualcurrency_100"; IStoreController m_StoreController; void Awake() { ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); builder.AddProduct(kProductID100Currency, ProductType.Consumable); UnityPurchasing.Initialize(this,builder); } public void PurchaseCurrency() { if (m_StoreController != null) { // Fetch the currency Product reference from Unity Purchasing Product product = m_StoreController.products.WithID(kProductID100Currency); if (product != null && product.availableToPurchase) { m_StoreController.InitiatePurchase(product); } } } public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { m_StoreController = controller; } public void OnInitializeFailed(InitializationFailureReason error) {} public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) { if (String.Equals(e.purchasedProduct.definition.id, kProductID100Currency, StringComparison.Ordinal)) { Debug.Log("Purchased 100 coins"); } return PurchaseProcessingResult.Complete; } public void OnPurchaseFailed(Product item, PurchaseFailureReason r) {} }

Variables

availableToPurchaseストアのサブシステムに基づいて、このプロダクトが購入可能かを判断します。
definitionプロダクトの不変の基本的属性
hasReceipt常にレシートがある NonConsumable (非消耗型) や Subscription (購読) かどうか。
metadataストアのシステムによって提供されるローカライズされたメタデータ
receipt可能な場合は、プロダクトの購入レシート。ない場合は null。
transactionIDある場合は、このプロダクトのトランザクションの一意の識別子。ない場合は、null。

Public Functions

EqualsEquality defined for use in collections.
GetHashCodeGetHashCode defined for use in collections.