/// <summary> /// Initiate shop manager initialization on scene change. /// </summary> public void OnLevelWasLoaded(int level) { if (instance != this) { return; } ShopManager shop = null; GameObject shopGO = GameObject.Find("ShopManager"); if (shopGO) { shop = shopGO.GetComponent <ShopManager>(); } if (shop) { shop.Init(); #if !UNITY_EDITOR if (controller != null) { ShopManager.OverwriteWithFetch(controller.products.all); } #endif } }
/// <summary> /// Detect and initiate the ShopManager initialization on scene changes. /// </summary> public void OnSceneWasLoaded(Scene scene, LoadSceneMode m) { if (instance != this) { return; } ShopManager shop = null; GameObject shopGO = GameObject.Find("ShopManager"); if (shopGO) { shop = shopGO.GetComponent <ShopManager>(); } if (shop) { shop.Init(); #if UNITY_PURCHASING && (!UNITY_EDITOR || PLAYFAB) if (controller != null) { ShopManager.OverwriteWithFetch(controller.products.all); } #endif } }
// Optionally: verify old purchases online. // Once we've received the product list, we overwrite // the existing shop item values with this online data public void OnInitialized(IStoreController ctrl, IExtensionProvider ext) { controller = ctrl; extensions = ext; if (validator && validator.shouldValidate(VerificationType.onStart)) { validator.Validate(); } if (ShopManager.GetInstance()) { ShopManager.OverwriteWithFetch(controller.products.all); } }
// iOS version: receive StoreKitProducts. // Optionally: verify old purchases online. // Once we've received the productList, we create a // cross-platform version of it and overwrite // the existing shop item values with this online data private void ProductDataReceived(List <StoreKitProduct> list) { if ((verificationType == VerificationType.onStart || verificationType == VerificationType.both) && !string.IsNullOrEmpty(serverUrl)) { VerifyReceipts(); } productCache = new List <IAPArticle>(); for (int i = 0; i < list.Count; i++) { productCache.Add(new IAPArticle(list[i])); } if (ShopManager.GetInstance()) { ShopManager.OverwriteWithFetch(productCache); } }
// Once we've received the productList, we create a // cross-platform version of it and overwrite // the existing shop item values with this online data // Optional: verify old purchases online. private void ProductDataReceived(Inventory inv) { //store fetched inventory for later access inventory = inv; //check for non-consumed consumables List <Purchase> prods = inv.GetAllPurchases(); for (int i = 0; i < prods.Count; i++) { IAPObject obj = GetIAPObject(prods[i].Sku); if (obj != null && obj.type == IAPType.consumable) { OpenIAB.consumeProduct(prods[i]); } } #if UNITY_ANDROID if ((verificationType == VerificationType.onStart || verificationType == VerificationType.both) && !string.IsNullOrEmpty(serverUrl)) { VerifyReceipts(); } #endif //build live cache productCache = new List <IAPArticle>(); for (int i = 0; i < ids.Length; i++) { if (inv.GetSkuDetails(ids[i]) != null) { productCache.Add(new IAPArticle(inv.GetSkuDetails(ids[i]))); } } if (ShopManager.GetInstance()) { ShopManager.OverwriteWithFetch(productCache); } }
// Android version: receive GoogleSkuInfos. // Optionally: verify old purchases online. // Once we've received the productList, we create a // cross-platform version of it and overwrite // the existing shop item values with this online data void ProductDataReceived(List <GooglePurchase> purchases, List <GoogleSkuInfo> list) { //store old purchases for verification purposes prods = purchases; if ((verificationType == VerificationType.onStart || verificationType == VerificationType.both) && !string.IsNullOrEmpty(serverUrl)) { VerifyReceipts(); } productCache = new List <IAPArticle>(); for (int i = 0; i < list.Count; i++) { productCache.Add(new IAPArticle(list[i])); } if (ShopManager.GetInstance()) { ShopManager.OverwriteWithFetch(productCache); } }