- Home /
void dont show up in on click
this code dont show up in the on click event in a button and i dont know why can anyone help my plzz?
public void BuyShip(GameObject shipPrefab, int iron, int gold, int wood)
{
if(BoatInv.gold >= gold && BoatInv.iron >= iron && BoatInv.wood >= wood)
{
BoatInv.gold = BoatInv.gold - gold;
BoatInv.iron = BoatInv.iron - iron;
BoatInv.wood = BoatInv.wood - wood;
GameObject Ship = Instantiate(shipPrefab, ShipSpawn.position, Quaternion.identity);
}
else
{
textLittleResourses.SetActive(true);
}
}
Comment
Best Answer
Answer by Eno-Khaon · May 09, 2018 at 06:53 PM
https://forum.unity.com/threads/ui-doesnt-accept-functions-with-more-than-two-arguments-or-arrays.306671/
You can only have a single argument in a function called by a UI button, and that argument must be fairly simple (such as bool, int, float).
That said, the linked forum thread offers a few ideas for alternative approaches.