I want to make an FPS with unity.
I am stuck with saving the game (Saving your progress and not the level in the editor).
Theoretically it would be easiest to save the entire scene or level in it's state. When you save it all the scripts, prefabs, models, terrains, particles, animations and variables are DYNAMICALLY saved into a separate file.
Then when you load the game again the scene file is loaded into the game and played on from the suspended saved version.
I would really like an answer to this, the reason I don't want to simply save a few variables to a text file is because my game has tons of stuff packed in it and this would require tons of individual data.
Answer by PeripheralV
Feb 04, 2012 at 11:36 PM
I think I'm working on a similar problem at the moment. The GameObject.FindObjectsOfType function will give you an array of all the objects in the scene.
Currently, I'm writing each object's position, rotation, and scale to disk, then using GameObject.GetComponent to retrieve the objects' MeshFilter component (if it has one) and saving the mesh's name to disk.
I'm hoping not to have to save the actual mesh data to disk, but rather to be able to read in the object's mesh's name and load the mesh itself by name. I've been searching for the answer to that one for a while...
In summary, GameObject.FindObjectsOfType will get you all your scene objects and GameObject.GetComponent will fetch individual components for you. Hope this helps.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
1 Person is following this question.
How can I dynamically create scene ?
Save & Load Game question
What Just Happened!
Obejects in the Scene disappear...