public ShopThingData(ShopThingData prod) { if (prod == null) { return; } name = prod.name; thingImage = prod.thingImage; thingLabelImage = prod.thingLabelImage; thingCount = prod.thingCount; thingPrice = prod.thingPrice; thingPriceText = prod.thingPriceText; thingCountText = prod.thingCountText; thingCountOldText = prod.thingCountOldText; kProductID = prod.kProductID; clickEvent = prod.clickEvent; }
public void SetData(ShopThingData shopThing) { if (thingImage) { thingImage.sprite = shopThing.thingImage; thingImage.SetNativeSize(); } if (thingTextCount) { thingTextCount.text = shopThing.thingCountText; } if (thingTextCountOld) { thingTextCountOld.text = shopThing.thingCountOldText; } if (thingTextPrice) { thingTextPrice.text = shopThing.thingPriceText; } if (thingLabelImage) { if (shopThing.thingLabelImage) { thingLabelImage.sprite = shopThing.thingLabelImage; thingLabelImage.SetNativeSize(); } else { thingLabelImage.gameObject.SetActive(false); } } if (thingBuyButton) { thingBuyButton.onClick.RemoveAllListeners(); thingBuyButton.onClick = shopThing.clickEvent; } if (thingName) { thingName.text = shopThing.name; } }
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); }
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); }