Load a lot of prefabs in a UnityScript

Hello,

I have a problem with my “prefab management” (I would call it so). I have started to code a “Map Designer” for my game. In this designer it is possible to place quadratic tiles (2D) which are different (grass, way, water, etc. - in different versions to). You can toggle the selected kind of tile by pressing T.

The problem now ist, that I have about 25 different tiles. My first way was that I have declared a public GameObject for each tile. So I have 25 public GameObjects in my script and i have to connect all this prefabs (each kind of tile is a prefab, tile an Box Collider, etc.)…I think there would be a better way to realise?

Do you have a clue for me to do this better?

Thank you!

Can’t you just have arrays?

Hello,

yes, I can have arrays. But I have just to load all prefabs in the script to put these in the array. So far as i know thats the same problem?

You can access the array in the editor and just drag all prefabs in, or you can put them in the Resources folder and use resouce.load

Oh yes, that works fine. I didn’t know that! Thank you!

1 Like