[SOLVED] Keeping prefabs positions after runtime

OK, so here is what I am trying to do.

I have a code that creates a spawnpoint at random position for a prefab, which in turn creates a lot of prefabs around this spawnpoint.
After this, a new spawnpoint is created at random position which in turn creates a lot of prefabs around this spawnpoint. And so it goes …

The problem is that I do not know how I can save the locations of all the prefabs so that it is not removed when I finish runtime. I want to be able to create it in the editor “with a button” or keep them after they are created in runtime so they become permanent, so to speak.

It would be very difficult and messy to place them manually on the terrain so to do it via code is perfect.

Is it very complicated?

I’m not 100% sure if I understand your question correctly, but I believe that you have to tell Unity, that your Scene has been changed by scripts.

You can do this by marking the Scene as dirty.
Prior to 5.3 and with additional information: Link

This solution is for Editor Scripts. I doubt that it is possible to save runtime changes to the scene.

1 Like

editor scripting isn’t “very complicated” at all, perhaps have a look at things like:

1 Like

Thanks for quick reply :slight_smile:

I will look into the editor scripting. It look like I dont have to recode everything for that to work