Currently trying to figure out how to load a lot of Prefabs automatically.
For my old Pac-Man test, I just did a hardcoded lame thing, as I knew how many prefabs I needed to load and they were less than a handfull, like this:
I know the objects - so just hardcoded load
`
GameObject goWall = (GameObject)Resources.Load(“Wall”);
GameObject goEnergy = (GameObject)Resources.Load(“Energy”);
GameObject goPill = (GameObject)Resources.Load(“Pill”);
GameObject goMonster = (GameObject)Resources.Load(“Monster”);
GameObject goPlayer = (GameObject)Resources.Load(“NomNomNom”);
`
Then later on, in the parsing of the leveldata (map):
wall
`
go = (GameObject)Instantiate(goWall,pos,Quaternion.identity);
go.name = “wall”+xcnt+“x”+ycnt; // to make realtime debugging easier
`
etc.
But now I am facing a project where the Prefabs will be PLENTY per level/area, lets just say maybe 100 or 200 (dont know the actual number before the full design is completed)
What I am asking is, how can I make a “list” of whats in a certain Ressource folder and then load them automatically? I can see we have Resources.LoadAll, but …?
I will use an Array to store the GameObjects, together with their “names”, but I cant figure out how to make a “directory” of the Ressource folder.
Secondly I would like to give them short names beside the actual Prefab name, if possible. But thats secondary if possible at all.