Class TransactionItemView
Component that manages displaying a BaseTransaction's icon, display name and PurchaseButton. When attached to a game object, it will display the Transaction Item's icon and displayName and create and display a PurchaseButton (PurchaseButton) to complete purchase transactions for it.
Inherited Members
Namespace: UnityEngine.GameFoundation.Components
Syntax
[AddComponentMenu("Game Foundation/Transaction Item View", 2)]
[ExecuteInEditMode]
public class TransactionItemView : MonoBehaviour
Fields
m_IsDirty
Tracks whether any properties have been changed. Checked by Update() to see whether content should be updated.
Declaration
protected bool m_IsDirty
Field Value
Type | Description |
---|---|
Boolean |
m_ShowDebugLogs
Specifies whether the debug logs is visible.
Declaration
protected bool m_ShowDebugLogs
Field Value
Type | Description |
---|---|
Boolean |
m_Transaction
The BaseTransaction to display in the view.
Declaration
protected BaseTransaction m_Transaction
Field Value
Type | Description |
---|---|
BaseTransaction |
onPurchasableStatusChanged
Callback that will get triggered any time itemPurchasableStatus changes.
Declaration
public TransactionItemView.PurchasableStatusChangedEvent onPurchasableStatusChanged
Field Value
Type | Description |
---|---|
TransactionItemView.PurchasableStatusChangedEvent |
onTransactionFailed
Callback that will get triggered if a purchase for any item in the store fails.
Declaration
public TransactionItemView.TransactionFailureEvent onTransactionFailed
Field Value
Type | Description |
---|---|
TransactionItemView.TransactionFailureEvent |
onTransactionSucceeded
Callback that will get triggered if a purchase for any item in the store completes successfully.
Declaration
[Space]
public TransactionItemView.TransactionSuccessEvent onTransactionSucceeded
Field Value
Type | Description |
---|---|
TransactionItemView.TransactionSuccessEvent |
Properties
badgeField
The ImageInfoView to assign the badge to.
Declaration
public ImageInfoView badgeField { get; }
Property Value
Type | Description |
---|---|
ImageInfoView |
badgeTextPropertyKey
The Static Property key for the badge to be displayed in callout.
Declaration
public string badgeTextPropertyKey { get; }
Property Value
Type | Description |
---|---|
String |
interactable
Use to enable or disable interaction on the TransactionItemView UI.
Declaration
public bool interactable { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
itemIconImageField
The Image component to assign the Transaction Item's icon image to.
Declaration
public Image itemIconImageField { get; }
Property Value
Type | Description |
---|---|
Image |
itemIconSpritePropertyKey
The Static Property key string that should be used for getting the item icon sprite of the Transaction Item for displaying in the view.
Declaration
public string itemIconSpritePropertyKey { get; }
Property Value
Type | Description |
---|---|
String |
itemNameTextField
The TextMeshProUGUI component to assign the item's display name to.
Declaration
public TextMeshProUGUI itemNameTextField { get; }
Property Value
Type | Description |
---|---|
TMPro.TextMeshProUGUI |
noPriceString
The string to display on PurchaseButton if the Transaction Item has no cost.
Declaration
public string noPriceString { get; }
Property Value
Type | Description |
---|---|
String |
priceIconSpritePropertyKey
The Static Property key string that should be used for getting the price icon sprite of the Transaction Item for displaying in the PurchaseButton.
Declaration
public string priceIconSpritePropertyKey { get; }
Property Value
Type | Description |
---|---|
String |
purchaseButton
The PurchaseButton to set with the TransactionItem's purchase info.
Declaration
public PurchaseButton purchaseButton { get; }
Property Value
Type | Description |
---|---|
PurchaseButton |
transaction
The BaseTransaction to display in the view.
Declaration
public BaseTransaction transaction { get; }
Property Value
Type | Description |
---|---|
BaseTransaction |
transactionKey
The key of the BaseTransaction being displayed.
Declaration
public string transactionKey { get; }
Property Value
Type | Description |
---|---|
String |
Methods
InitPurchaseButton()
Inits the purchaseButton with the transactionKey, priceIconSpritePropertyKey, and noPriceString.
Declaration
protected void InitPurchaseButton()
OnSpriteLoadFailed(String)
Callback for if there is an error while trying to load a sprite from its Property.
Declaration
protected void OnSpriteLoadFailed(string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
String | errorMessage | The error message returned by UnityEngine.GameFoundation.Components.PrefabTools.LoadSprite(UnityEngine.GameFoundation.Property,System.Action{UnityEngine.Sprite},System.Action{System.String}). |
SetBadgeField(ImageInfoView)
Sets the ImageInfoView component to display the transaction's badge on this view.
Declaration
public void SetBadgeField(ImageInfoView badge)
Parameters
Type | Name | Description |
---|---|---|
ImageInfoView | badge | The ImageInfoView component to display the transaction's badge. |
SetBadgeTextPropertyKey(String)
Sets the Static Property key that will be used when displaying the transaction's badge.
Declaration
public void SetBadgeTextPropertyKey(string propertyKey)
Parameters
Type | Name | Description |
---|---|---|
String | propertyKey | The key that is defined in the transaction's static properties for the transaction's badge. |
SetIconSprite(Sprite)
Sets the transaction's icon with the given sprite.
Declaration
protected void SetIconSprite(Sprite itemSprite)
Parameters
Type | Name | Description |
---|---|---|
Sprite | itemSprite | The sprite to show on the transaction game object. If null, a blank image will be shown. |
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. |
SetItemIconImageField(Image)
Sets the Image component to display item icon sprite on this view.
Declaration
public void SetItemIconImageField(Image image)
Parameters
Type | Name | Description |
---|---|---|
Image | image | The Image component to display item icon sprite. |
SetItemIconSpritePropertyKey(String)
Sets the Static Property key for Transaction Item icon that will be displayed on this view.
Declaration
public void SetItemIconSpritePropertyKey(string propertyKey)
Parameters
Type | Name | Description |
---|---|---|
String | propertyKey | The Static Property key that is defined on Transaction Item for item icon sprite. |
SetItemNameTextField(TextMeshProUGUI)
Sets the TextMeshProUGUI component to display item name on this view.
Declaration
public void SetItemNameTextField(TextMeshProUGUI text)
Parameters
Type | Name | Description |
---|---|---|
TMPro.TextMeshProUGUI | text | The TextMeshProUGUI component to display the item name. |
SetNoPriceString(String)
Sets the string to display on PurchaseButton 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. |
SetPriceIconSpritePropertyKey(String)
Sets the Static Property key for price icon that will be displayed on PurchaseButton.
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. |
SetPurchaseButton(PurchaseButton)
Sets PurchaseButton to be able to purchase Transaction Item by UI.
Declaration
public void SetPurchaseButton(PurchaseButton purchaseButton)
Parameters
Type | Name | Description |
---|---|---|
PurchaseButton | purchaseButton | The PurchaseButton to display price and price icon and to be able to purchase the TransactionItem by using UI. |
SetTextContent(String, String)
Sets the transaction's displayName and badge text in their respective fields.
Declaration
protected void SetTextContent(string itemDisplayName, string badgeText)
Parameters
Type | Name | Description |
---|---|---|
String | itemDisplayName | Transaction's display name. |
String | badgeText | Badge text to be displayed. |
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. |
UpdateContentAtRuntime()
To update the item name, item icon, and PurchaseButton at runtime.
Declaration
protected virtual void UpdateContentAtRuntime()