- Home /
How do you stop Unity from removing items from an array during runtime?
Hello! I'm having an issue with an inventory script that I've been working on, and I've just figured out that the array for the inventory is being deleted on startup. Does anyone know why this is happening? Below are pictures of my shop code and inventory code. They use the same code, but the shop initializes normally and keeps the array filled with slots.
[1]: /storage/temp/193639-inventoryforquestin.png
Answer by VioletAbstract · Mar 14 at 09:45 PM
If you are creating an inventory system where the order of items will change, or if items will be added or removed during runtime, use a List rather than an Array.
Your answer
Follow this Question
Related Questions
Insert a semicolon error 1 Answer
Unity giving errors when the program starts 1 Answer
Navmesh error on instantiated navmesh agents 1 Answer
Error BCE0044 plz help 0 Answers
i can't export 0 Answers