Get an Int from a prefab.
I have a prefab of a store. This store has a count integer in it to signify how many things the store is holding. But this prefab populates many stores with different int values. So store one could have 3 items while store 2 has 40 items and so forth. I need a way to add all of those up and use it in another script. I don't even know where to start. An answer would be ideal but if not just a nudge in the right direction would be greatly appreciated. Thank you in advance.
Answer by evanatan · Apr 30, 2021 at 11:42 AM
Hi,
So let me understand, you have one prefab store which include multiples stores ? Or have you a prefab store with the count integer for each store ?
Can't you just drag and drop your prefabs and then use it in scripts like any other gameobjects ?
I have one prefab that instantiates multiple stores from the same prefab, each of those stores have their own amount of supplies in the store. I just need to be able to access each individuals prefabs int supplies and get a total of that. I will see if I can figure it out by making a public gameobject and dragging that in. Thank you.
Your answer
Follow this Question
Related Questions
Instantiate prefab by total int 1 Answer
Turning a int into a possibility of 19 different outcomes 1 Answer
Why am I unable to Instantiate a single cube from script? 0 Answers
Acces position of previously instantied prefab 0 Answers
Are there any pitfalls for putting space in GameObject/Prefab names? 1 Answer