private void CreateThingTab() { ShopThingHelper[] sT = ThingsParent.GetComponentsInChildren <ShopThingHelper>(); foreach (var item in sT) { DestroyImmediate(item.gameObject); } Purchaser p = Purchaser.Instance; if (p == null) { return; } List <ShopThingDataReal> products = new List <ShopThingDataReal>(); VideoPurchaser vP = VideoPurchaser.Instance; if (vP && vP.gameProducts != null && vP.gameProducts.Length > 0) { products.AddRange(vP.gameProducts); } if (p.consumable != null && p.consumable.Length > 0) { products.AddRange(p.consumable); } if (p.nonConsumable != null && p.nonConsumable.Length > 0) { products.AddRange(p.nonConsumable); } if (p.subscriptions != null && p.subscriptions.Length > 0) { products.AddRange(p.subscriptions); } Debug.Log("products count: " + products.Count); if (products.Count == 0) { return; } shopThings = new List <ShopThingHelper>(); for (int i = 0; i < products.Count; i++) { if (products[i] != null && (products[i].shopType == shopType) && products[i].prefab) { shopThings.Add(ShopThingHelper.CreateShopThingsHelper(products[i].prefab, ThingsParent, products[i])); } } if (scrollFlag) { scrollFlag.SetActive(products.Count > 4); } }
private void CreateThingTab() { ShopThingHelper[] sT = ThingsParent.GetComponentsInChildren <ShopThingHelper>(); foreach (var item in sT) { DestroyImmediate(item.gameObject); } InGamePurchaser p = InGamePurchaser.Instance; if (p == null) { return; } List <ShopThingDataInGame> products = new List <ShopThingDataInGame>(); if (p.gameProducts != null && p.gameProducts.Length > 0) { products.AddRange(p.gameProducts); } if (products.Count == 0) { return; } shopThings = new List <ShopThingHelper>(); for (int i = 0; i < products.Count; i++) { Debug.Log(ID + " : " + products[i].kProductID); if (string.IsNullOrEmpty(ID) || ID.Contains(products[i].kProductID)) { if (products[i] != null && (products[i].shopType == shopType) && products[i].prefab) { shopThings.Add(ShopThingHelper.CreateShopThingsHelper(products[i].prefab, ThingsParent, products[i])); } } } if (caption && !string.IsNullOrEmpty(ShopCaption)) { caption.text = ShopCaption; } if (scrollFlag) { scrollFlag.SetActive(products.Count > 2); } ID = null; ShopCaption = null; }
public static ShopThingHelper CreateShopThingsHelper(GameObject prefab, RectTransform parent, ShopThingData shopThingData) { if (!prefab) { return(null); } GameObject shopThing = UnityEngine.Object.Instantiate(prefab); shopThing.transform.localScale = parent.transform.lossyScale; shopThing.transform.SetParent(parent.transform); ShopThingHelper sC = shopThing.GetComponent <ShopThingHelper>(); sC.SetData(shopThingData); return(sC); }
public static ShopThingHelper CreateShopThingsHelper(GameObject prefab, RectTransform parent, ShopThingData shopThingData) { if (!prefab) { return(null); } prefab.GetComponent <ShopThingHelper>().SetImages(shopThingData.thingImage, shopThingData.thingLabelImage); // fix 2019 unity GameObject shopThing = Instantiate(prefab); shopThing.transform.localScale = parent.transform.lossyScale; shopThing.transform.SetParent(parent.transform); ShopThingHelper sC = shopThing.GetComponent <ShopThingHelper>(); sC.SetData(shopThingData); return(sC); }
private void CreateThingTab() { ShopThingHelper[] sT = ThingsParent.GetComponentsInChildren <ShopThingHelper>(); foreach (var item in sT) { DestroyImmediate(item.gameObject); } InGamePurchaser p = InGamePurchaser.Instance; if (p == null) { return; } List <ShopThingDataInGame> products = new List <ShopThingDataInGame>(); if (p.gameProducts != null && p.gameProducts.Length > 0) { products.AddRange(p.gameProducts); } if (products.Count == 0) { return; } shopThings = new List <ShopThingHelper>(); for (int i = 0; i < products.Count; i++) { if (products[i] != null && (products[i].shopType == shopType) && products[i].prefab) { shopThings.Add(ShopThingHelper.CreateShopThingsHelper(products[i].prefab, ThingsParent, products[i])); } } }