Is there possible to save scene gameobject data on external file? (not in the registry)

I got a system where i cans save object position in my scene. It saves in the computer registry. This means that i can load my saved scene up only in the same computer it was saved in. I want to create a system where i save a scene and all its data will be written on an external file. I can then pass this file around and someone else who runs the same program on another computer can load up the file and read all the gameobject position data from it.

Can it be done and if so then how? (my program is a standalone executable)


You answered the question yourself.

You can export your data of object positions to an xml file or any format you want to. The application then read the file and populate objects with information stored.

Ah ha! In fact, there is a more “optimized” way – try this:

using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

string filePath = Application.dataPath + "position.dat";
PositionData positionData;

using(FileStream s = new FileStream(filePath, FileMode.Create) )
   BinaryFormatter b = new BinaryFormatter();
   b.Serialize(s, positionData);

BTW, I haven’t tested this myself, so there may be errors, but I know this is a simple technique for doing what you are trying to do. Play around a bit and see how it goes.