What's the easiest way to serialize entire gameobjects or only of components ? ;)
Asked
Active
Viewed 593 times
1 Answers
0
You'll need to add [Serializable] before the public class yourClass. Then do something like this to serialize the data:
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create ("savefile"); //you can call it anything you want
bf.Serialize(file, GameObjectToBeSerialized);
file.Close();`
Here's some documentation, the first is to the unity source on how to do these and then to the unity's community forum. https://unity3d.com/learn/tutorials/topics/scripting/persistence-saving-and-loading-data http://answers.unity3d.com/questions/967840/saving-your-scene-and-location-in-game.html
Jonathan Van Dam
- 599
- 8
- 22