0

What's the easiest way to serialize entire gameobjects or only of components ? ;)

DonDaro
  • 1
  • 2
  • 3
  • 2
    Welcome to SO. One line question is not good. Please explaining what you are doing and why you need to serialize a GameObject.... – Programmer Jan 29 '17 at 02:19

1 Answers1

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
  • 630
  • 9
  • 23