How to manage list of contents²


I am working on a mall building sim. So I have a list of “shops” and stuff like that, which will have different properties and so on.

I am wondering what is the best way to manage the list so I can easily add / delete elements and then call them in my game. The best would be to be able to tweak them directly in the inspector.

I thought of using prefabs but the problem is that I will have to assign manually the prefabs to the elements that use them…

Does anyone knows a nice and clean way to manage game content ?

Thanks :slight_smile:

You want Array, or HashTable, or ArrayList. ArrayList is very popular. And you want to make a ‘struct’ or ‘class’ containing the data you want. Ex:

In jscript:

class Shop {
var name : String;
var location : Transform;
var address : String;
var owner : String;
var inventory : ArrayList;

Then you can use the methods on ArrayList as described here to add, delete, access lists of Shops, and note I put ‘inventory’ as an ArrayList also, so each shop has a list of its own containing inventory classes. I’ll leave it to you to determine what goes there, but I would think product name, UPC, price, manufacturer, etc.

Well basically I’m looking for a nice way to manage my gameObjects list. For exemple on an adventure game if I want to create 300 ennemies, how would I manage them ? Like, storing them on prefabs, creating a file describing them ?

I need a way to be able to get the list and use it easily in my game, without having to manually assign / unassign any new object I create

I think I would have started with setting up some basic classes, like Shop and so on. which include the basic shop properties which all shops have. An example: Area, customers, opening times etc. Then I would have created some classes like: ElectronicsStore, FoodsMarket etc. which inherit from the class Shop and will include information like the name of the shop and the reference to a prefab for this shop and etc.

Then when you build a shop, you just make a object of one of the classes (for example: FoodsMarket) and sets its properties and prefab to use. You have to be familiar with classes though. You can also go a step further and make classes like BobsCoolShop etc, which inherit for example from a class of ToyStore.