Copy procedurally generated game objects out of play mode into editor

I have a bunch of script that procedurally generate a number of game objects that make up my map for the game I’m making. When I run the game, everything is generated and all is working well.

The problem is, I want to now copy the generated objects out of the hierarchy window in play mode, and paste them into the hierarchy in edit mode so I can edit the map further. Initially I thought I would just be able to copy/paste, but clearly that doesn’t work

This tool is not part of my game, I wrote it to help me build the map for the game, so I’m not looking to procedurally generate levels and save them, I just want to run it once and copy/save the results to carry on editing

Any suggestions on how to accomplish this?

Shouldn’t your script be an editor script then?

You might want to look into EditorUtility.SetDirty.