I managed to have a basic map generation algorhytm, but now it needs some content.

I generate abstract map data, which then will be used to build the map itself.

When I want to generate monsters, chests, entrances, etc, I have a prefab, and I will determine it's placement, then register it in the mapdata.

The problem is that I want to configure them as well, like affixes, stats, or where those entrances lead, etc. But the component is only available after the map is built. At generation I have only the prefab, so I have to transfer the generated configuration to the map builder somehow.

If I could clone the prefab, modify the clone's values and store that prefab.. . that would be great. But I can only instantiate prefabs, and I can't clone them without making a new asset.


1 Answer 1


You can simply Instantiate the prefab, disable it, modif it, and keep it as a reference.

Once you need it, simply call Instantiate on the disabled gameobject, and use the result.

  • \$\begingroup\$ Instantiating GameObjects wouldn't cause some performance issues during the generation? And then during map building they all have to be deleted. \$\endgroup\$
    – Tudvari
    Commented Jan 24, 2020 at 7:26
  • \$\begingroup\$ Unless you're instantiating thousands of them per second, the performance difference will be minimal. If you are, then you need to reuse the same gameobjects as best you can. Of course, you should delete any unused go, unless you're using some sort of pool. \$\endgroup\$ Commented Jan 25, 2020 at 2:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .