Hey everyone
I have a little problem with a button script i’ve made basically when the button is pressed it will subtract just the item amounts required, however on click it is carrying out approximatly 800 operations per click
Is there a way around this?
Button button = tooltip.transform.GetChild(4).GetComponent<Button>();
button.onClick.RemoveAllListeners();
button.onClick.AddListener(delegate {StartCoroutine(Create(craft));});
IEnumerator Create(Crafts craft)
{
yield return new WaitForSeconds(0.1f);
inventory.addItem(craft.itemreference);
Resourcesubtract(craft.craftWood, craft.craftStone, craft.craftMetal);
}
Thanks in advance