I’ve got a prefab (generic store item) being loaded into a panel, and I’m using a parent gameobject to update all store items with their correct info - item name, image etc etc, which is all simple enough reading/writing from Lists.
However, loading in the button is a little more difficult - I need it to first take in an existing object in the scene (which contains attached scripts that handle the store/item logic), into the OnClick() component. I then need to ensure the OnClick() is set to call the correct function (buyThis(int n)), and also pass through a value for n.
Can anyone point me in the right direction on this?
Edit: For clarity, here’s the prefab below:
So under On Click(), I need to attach this to an object that’s not a prefab - but is actually in the scene. Following this, I need to set the actual method that I want to be called, and set the int argument. Here’s a manually placed one;
So, in this one we can see the object attached, the method/function selected, and a value inserted for the required int argument.
In short, when instantiating/placing the prefab into the scene, I need to insert custom values for the gameobject to be loaded, and then for the method & arguments to be updated too.