scripting OnClick to just affect one instance of the script.

Hi my issue is I have made a campfire prefab that can be instantiated by the player in numerous locations in world space This fire has its own script which upon activation by player raycast, there is inventory menu where wood can be added and removed. this works fine but upon more than one fire being placed in the world. the onclick listener seems to add wood to them all.

this is line i used to call button.

button.onClick.AddListener(delegate () { AddWoodfunction(); });

is there a way to have the onclick only effect the one script and not all the fires.
sorry if this sounds confusing!!
Thanks in advance

maybe try accessing the script through an individual object…

Well, you could remove the listener when you close the menu.

// Open Menu

// Close Menu