- Home /
How to save positions of many instantiated objects during runtime into the editor?
Hello Everyone, In my current game scene, I have a hundred or so gameobjects instantiating during runtime by script. Some objects are being positioned by the RigidBody Component until they are settled. What I want to do is find a way to memorize/save the position of all these objects. I don't want users to have to wait and run their CPU for these objects to settle in the correct place on the scene. Before they can begin playing on my map. Also, Is it possible to save the runtime instantiated objects so that if I pressed the stop button on the editor. They would remain in my scene, allowing me to edit some of the objects positions?
I'm guessing the best way to do this is to first use some script to safe all the positions into a file with an array. Then somehow have an editor script read that file? then add the objects to scene?
To summarize; How do I save the instantiated objects and positions during runtime, into the editor when I press the editor game stop button.
Any guidance or documentation on this would be great thanks!
Answer by Polinator · Mar 14, 2013 at 09:22 PM
I had this same problem before, had many balls rolling down a hill and needed to save their positions.
I also thought I needed an array, or a text document saving the posisitons of everything and then writing it again during runtime. Also, there are many programs that you can copy/edit during runtime, then load into the editor.
However, I simply just paused the game where I wanted to get my game objects, then selected all and copy. After stopping, I pasted them all into the hierarchy. This might work for you, too.
Wow, That was quite a simple solution. I feel like I should have known that by now...This should cover my problems for now
Thanks!