Question by
tanz · Jan 21, 2016 at 10:33 PM ·
uibuttonbutton trigger eventsevent-listener
UI Button click event through script
Well i am creating an inventory system that is likea a scrollview, and in that scroll view, i have buttons which are put in there at runtime, i want to ( at runtime) add a unity event to those buttons that triggers the UseItem, which sends a string or maybe a int to determine what is being clicked.
Comment
Answer by FlamingGenius · Jan 21, 2016 at 11:22 PM
create an empty object in the hierarchy then add a script to the object as a component edit the script and this should get you started
public void FuctionName(parameters if any go here){ //code to execute }
on your button in the onclick select your empty gameobject and then select the function and when the button is clicked in the game it will execute the function