- Home /
Question by
unity_YDXy-j36vRpfiQ · Dec 02, 2020 at 12:33 AM ·
gameobjectbuttonscript.
How can i add a fuction to a button by code???
Im trying to add a fuction to the button but it needs a gameobject to get the fuction, but i need to add the game object by script. I've been trying this:
inventory.itemInventory[i].GetComponent().onClick.AddListener(UseItem);
but seems like it can't find the gameobject.
Comment