Class PurchaseButton
Component for completing a purchase using the ITransactionManager.
Inherited Members
Namespace: UnityEngine.GameFoundation.Components
Syntax
[AddComponentMenu("Game Foundation/Purchase Button", 3)]
[RequireComponent(typeof(Button))]
[ExecuteInEditMode]
public class PurchaseButton : MonoBehaviour
Fields
onPurchasableStatusChanged
Callback that will get triggered any time itemPurchasableStatus changes.
Declaration
public PurchaseButton.PurchasableStatusChangedEvent onPurchasableStatusChanged
Field Value
Type | Description |
---|---|
PurchaseButton.PurchasableStatusChangedEvent |
onPurchaseFailure
Callback that will get triggered if item purchase fails.
Declaration
public PurchaseButton.TransactionFailureEvent onPurchaseFailure
Field Value
Type | Description |
---|---|
PurchaseButton.TransactionFailureEvent |
onPurchaseSuccess
Callback that will get triggered if item purchase completes successfully.
Declaration
public PurchaseButton.TransactionSuccessEvent onPurchaseSuccess
Field Value
Type | Description |
---|---|
PurchaseButton.TransactionSuccessEvent |
Properties
interactable
Use to enable or disable the button.
Declaration
public bool interactable { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
itemPurchasableStatus
The PurchasableStatus of the Transaction attached to this PurchaseButton.
Declaration
public PurchasableStatus itemPurchasableStatus { get; }
Property Value
Type | Description |
---|---|
PurchasableStatus |
noPriceString
The string to display if the Transaction Item has no cost.
Declaration
public string noPriceString { get; }
Property Value
Type | Description |
---|---|
String |
priceIconImageField
The Image component to assign the Transaction Item's cost icon to.
Declaration
public Image priceIconImageField { get; }
Property Value
Type | Description |
---|---|
Image |
priceIconSpritePropertyKey
The Static Property key string that should be used for getting the price icon sprite of the Transaction Item for displaying in the this view.
Declaration
public string priceIconSpritePropertyKey { get; }
Property Value
Type | Description |
---|---|
String |
priceTextField
The Text component to assign the price text to.
Declaration
public TextMeshProUGUI priceTextField { get; }
Property Value
Type | Description |
---|---|
TMPro.TextMeshProUGUI |
transaction
The BaseTransaction being purchased.
Declaration
public BaseTransaction transaction { get; }
Property Value
Type | Description |
---|---|
BaseTransaction |
transactionKey
The identifier of the Transaction Item being purchased.
Declaration
public string transactionKey { get; }
Property Value
Type | Description |
---|---|
String |
Methods
Purchase()
Calls BeginTransaction(BaseTransaction, List<String>) from transactions with the purchase detail of the Transaction Item displayed in the button. Is automatically attached to the onClick event of the PurchaseButton.
Declaration
public void Purchase()
SetInteractable(Boolean)
Sets the button's interactable state if the state specified is different from the current state.
Declaration
public void SetInteractable(bool interactable)
Parameters
Type | Name | Description |
---|---|---|
Boolean | interactable | Whether the button should be enabled or not. |
SetNoPriceString(String)
Sets the string to display when there is no cost defined in the Transaction Item.
Declaration
public void SetNoPriceString(string noPriceString)
Parameters
Type | Name | Description |
---|---|---|
String | noPriceString | The string to display. |
SetPriceIconImageField(Image)
Sets the Image component to display price icon sprite on the button.
Declaration
public void SetPriceIconImageField(Image image)
Parameters
Type | Name | Description |
---|---|---|
Image | image | The Image component to display price icon sprite. |
SetPriceIconSpritePropertyKey(String)
Sets the Static Property key for price icon that will be displayed on this view.
Declaration
public void SetPriceIconSpritePropertyKey(string propertyKey)
Parameters
Type | Name | Description |
---|---|---|
String | propertyKey | The the Static Property key that is defined on Transaction Item for price icon sprite. |
SetPriceTextField(TextMeshProUGUI)
Sets the Text component to display price text on the button.
Declaration
public void SetPriceTextField(TextMeshProUGUI text)
Parameters
Type | Name | Description |
---|---|---|
TMPro.TextMeshProUGUI | text | The Text component to display the texts on buttons |
SetTransaction(BaseTransaction)
Sets Transaction Item should be displayed by this view.
Declaration
public void SetTransaction(BaseTransaction transaction)
Parameters
Type | Name | Description |
---|---|---|
BaseTransaction | transaction | A reference to BaseTransaction that should be displayed. |