- Home /
Storing Prefab in an Array
So I am creating an inventory script where the player is able to store items by placing them in an array, the object is then removed from the scene
However, deleting the scene reference deletes the object in the array. How can I store the information for the items and remove them from the scene?
I've made sure that the object in the array is in a prefab. It is important that the object is deleted, and that all the information from the prefab is stored.
Answer by Joshua · Aug 17, 2011 at 09:58 PM
An easier way of doing this would be to simply de-activate the gameObject when it's placed in the inventory. Then, when it's retrieved from the inventory you activate it again and you set it's position to the 'spawnposition' of the 'new' gameobject. This way you can avoid having to keep creating and destroying GO's, but you rather just hide them for later.
The biggest problem is that I will be moving through scenes constantly, and the item needs to remain in the player's inventory. So I need to set the reference of the object, ins$$anonymous$$d of the object it's self.
Your answer
Follow this Question
Related Questions
Destroying Instantiated Prefab 1 Answer
OverlapSphere for parallel arrays 1 Answer
Assigning Instantiated Tiles to Array 1 Answer
add spawned GameObjects in an array C# 1 Answer
inventory system issues 0 Answers