예제 #1
0
        public void InitializeStore()
        {
            Debug.Log("Initializing Store");

            var catalogJson = LocalDataManager.Instance.GetConfigJson(typeof(ProductCatalog).Name);

            _productCatalog = ProductCatalog.Deserialize(catalogJson);

            if (IsInitialized())
            {
                OnInitSuccess.SafeInvoke();
                return;
            }

            if (_isInitializing)
            {
                return;
            }

            _isInitializing = true;
            var module  = StandardPurchasingModule.Instance();
            var builder = ConfigurationBuilder.Instance(module);

/*        var settings = new JsonSerializerSettings
 *      {
 *          NullValueHandling = NullValueHandling.Ignore,
 *          MissingMemberHandling = MissingMemberHandling.Ignore
 *      };
 *
 *      _productCatalog = JsonConvert.DeserializeObject<ProductCatalog>(catalogJson, settings);*/

#if UNITY_IOS
            appleConfig = builder.Configure <IAppleConfiguration> ();
#endif
            foreach (var product in _productCatalog.allProducts)
            {
                Debug.Log("Product: " + product.id + ", type: " + product.type);
                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);
                }
                else
                {
                    builder.AddProduct(product.id, product.type);
                }
            }

            UnityPurchasing.Initialize(this, builder);
        }