Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

Product

class in UnityEngine.Purchasing

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual

Descripción

Represents a product that may be purchased as an In App Purchase.

Here is an example of a sample Store class working with a Product referencs.


        
using System;
using UnityEngine;
using UnityEngine.Purchasing;

public class MyStoreClass : MonoBehaviour, IStoreListener { static string kProductID100Currency = "virtualcurrency_100"; IStoreController m_StoreController; void Start() { 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

availableToPurchaseDetermine if this product is available to purchase according to the store subsystem.
definitionFundamental immutable product properties.
hasReceiptOwned Non Consumables and Subscriptions should always have receipts.
metadataLocalized metadata provided by the store system.
receiptThe purchase receipt for this product, if owned. Otherwise null.
transactionIDA unique identifier for this product's transaction, if available. Otherwise null.