/// Populate a ConfigurationBuilder with products from a ProductCatalog public static void PopulateConfigurationBuilder(ref ConfigurationBuilder builder, ProductCatalog catalog) { foreach (var product in catalog.allValidProducts) { IDs ids = null; if (product.allStoreIDs.Count > 0) { ids = new IDs(); foreach (var storeID in product.allStoreIDs) { ids.Add(storeID.id, storeID.store); } } #if UNITY_2017_2_OR_NEWER var payoutDefinitions = new List <PayoutDefinition>(); foreach (var payout in product.Payouts) { payoutDefinitions.Add(new PayoutDefinition(payout.typeString, payout.subtype, payout.quantity, payout.data)); } builder.AddProduct(product.id, product.type, ids, payoutDefinitions.ToArray()); #else builder.AddProduct(product.id, product.type, ids); #endif } }
private IAPButtonStoreManager() { catalog = ProductCatalog.LoadDefaultCatalog(); StandardPurchasingModule module = StandardPurchasingModule.Instance(); module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser; ConfigurationBuilder builder = ConfigurationBuilder.Instance(module); foreach (var product in catalog.allProducts) { if (product.allStoreIDs.Count > 0) { var ids = new IDs(); foreach (var storeID in product.allStoreIDs) { ids.Add(storeID.id, storeID.store); } builder.AddProduct(product.id, product.type, ids); Debug.Log(string.Format("Add Product: {0}", product.id)); } else { builder.AddProduct(product.id, product.type); Debug.Log(string.Format("Add Product: {0}", product.id)); } } UnityPurchasing.Initialize(this, builder); }