Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections.Generic;
- using Prime31;
- namespace HutongGames.PlayMaker.Actions
- {
- [ActionCategory("Gets the price of a In App Purchase")]
- [Tooltip("Get Price")]
- public class GetPrice : FsmStateAction
- {
- [RequiredField]
- [Tooltip("product ID from iTunesConnect. MUST match exactly what you have there!")]
- public FsmString identifier;
- [RequiredField]
- [Tooltip("Where to store the price, it is a string containg the currency symbol as well. Example $1.99")]
- public FsmString price;
- public override void OnEnter()
- {
- #if UNITY_IOS || UNITY_ANDROID
- price.Value = GetProductPrice(identifier.Value);
- #endif
- Finish();
- }
- #if UNITY_IOS
- public string GetProductPrice(string identifier) {
- var products = StoreKitHelper.Instance.GetProducts();
- for(var i = 0; i < products.Count; ++i) {
- if(products[i].productIdentifier == identifier)
- return products[i].price;
- }
- return "Error. Product not found";
- }
- #elif UNITY_ANDROID
- public string GetProductPrice(string identifier) {
- var products = StoreKitHelper.Instance.GetSkus();
- for(var i = 0; i < products.Count; ++i) {
- if(products[i].productId == identifier)
- return products[i].price;
- }
- return "Error. Product not found";
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement