Hi. I am making inventory system where when you pick up item in inventory creates slot with sprite, name, etc. of item (GetComponent<>()).
But i want slot to get script with OnUse function, that depends on item that you pick up.
And i want all items to has individual OnUse function to be in one Item script, because if i will make scripts with unique function for each item i wouldn’t be able to get script components of items that i pick up because it has different names. I could use a bunch of if statement, but it would be very laggy for a lot of items and i would need to write there each item i added.
So i want script with individual function for each item that has it, and that i can edit this function for each item (like public string, float, bool, … variables).And i want to be able to translate this function to slot script.
Or i want public script variable where i can drop script like public gameObject variable, so this script contains OnUse function.** And ** i want to be able to translate this script variable to slot script.
Or you can suggest your solution for this problem
(All scripts on c#)
Maybe I spell something wrong, sorry for bad English.