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.
asked May 17 '11 at 11:22 AM
Anonymous game developer
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.