序列化整个游戏对象或仅限组件的最简单方法是什么? ;)
答案 0 :(得分:0)
您需要在[Serializable]
之前添加public class yourClass
。然后执行类似这样的操作来序列化数据:
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create ("savefile"); //you can call it anything you want
bf.Serialize(file, GameObjectToBeSerialized);
file.Close();`
这里有一些文档,第一个是关于如何做这些的统一来源,然后是团结的社区论坛。 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