- Home /
Save scene state
Hi guys,
i'm new to unity and i'm trying to make a physics based drag and drop game, where the user drag items around the screen and then press play to make the items interact. If the user does not like the way the items interact, there is a reset button that allows the user to edit the items position. At this moment that button only restarts the scene, making me lose every object tha was already placed on the screen. I want to know if there is a way to save the scene before pressing play, so that when reset is pressed the game came back to that state.
I think i could do that by adding a script that saves the position of each item, and then when reset is pressed, instantiate each of that items to the original position, but it seems like a rough solution.
Any idea will be appreciated
Thanks
Answer by Berenger · Jun 08, 2012 at 01:27 AM
It's actually a quite appropriate solution. There is nothing to make a snapshot of the game at a given time, so you have to code the save process yourself. On a single scene, store the positions as you said, accross scene you'll need to use static vars, DonDestroyOnLoad or PlayerPrefs, among other ways.
Thank you so much for your quick reply, i'll try that. Will come back to tell the results
Answer by pudd1nG · Jun 08, 2012 at 03:27 AM
If you want players to be able to save and load these scenes too then PlayerPrefs is your best bet. I would look at this extension for player prefs which lets you use vector3 among others. http://unifycommunity.com/wiki/index.php?title=ArrayPrefs
Answer by jcospina · Jun 08, 2012 at 01:35 PM
Thank you so much for your answers, unfortunatelly i can't vote your replies, but thumbs up. i'll try all of them and see wich one works for the best.
Your answer
Follow this Question
Related Questions
save level state by .. creating scene at runtime?! 0 Answers
Creating/Saving prefabs during runtime? 7 Answers
Real Time Multi-Developer Level Editing 0 Answers
How to save all scene? 1 Answer