x


Saving usermade creations in game

I'm making a game where the player is able to make things in game, ranging from a building to weapons and gear they will use. Right now focusing I'm on the Buildings and trying to figure out what would be the best way to save the creations. Should use Xml files, playerperfs or something else. Keep in mind that for the building side of things the player can build a whole town if he or she so wish.

more ▼

asked May 03 '12 at 10:28 PM

Sinperhezine gravatar image

Sinperhezine
13 4 6 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The 3 main options are PlayerPrefs or C# serialization or a text format, XML being the most obvious. If you want to be able to read/edit the save files outside of Unity then I would suggest XML, otherwise use C# serialization.

PlayerPrefs (documentation here) seems to be for storing small amounts of data and only handles ints, floats and strings. You will find it difficult to fit a whole town in this manner! Also, on Windows PlayerPrefs are stored in the registry - not a good idea to store too much there.

C# Serialization will require some coding on your part to get it set up and you will need to decide where to save the resulting files. It produces small save files, but you won't be able to look at them in other tools as they will be in binary format. There are some details on how to do this at the answer to this question. If you don't want users (or yourself) to be able to look and edit the save files, this is probably the best choice.

The other format is XML. It should require about as much coding as C# Serialization, but the save files will be larger. However, you will be able to read them as text. More details on this web page.

more ▼

answered May 04 '12 at 09:06 AM

cordinc gravatar image

cordinc
169 2 5

About C# serialization can i take the save data out of one game and move to another?

May 04 '12 at 11:08 AM Sinperhezine

Yes, if the other game has the same C# deserialization code into the same C# classes (that is both games share the same object model).

May 04 '12 at 06:59 PM cordinc
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2087
x295
x255
x133

asked: May 03 '12 at 10:28 PM

Seen: 541 times

Last Updated: May 04 '12 at 06:59 PM