x


Best method to store files ?

Hello Im making a trading card game.

What would be the best way to store the decks my user created?

  • Database (mysql) but needs sql server
  • Txt file, hard to read/write.
  • XML (Couldnt get it work)
  • Other ways? ...

Thanks

more ▼

asked May 24 '10 at 09:25 PM

Tobias gravatar image

Tobias
393 50 54 66

I don't know about the best way, but another way to store data (and the built in way in Unity), is to use PlayerPrefs, though that might not be best if you want to share decks, and there's a 1Mb memory limit in web apps: http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.html

May 24 '10 at 09:34 PM straydogstrut
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Without knowing what type of data it is (exactly), it's hard to say.

You'd probably be best off using a file or series of files, and using the Application.dataPath property to know where to read and write your files to (excluding the web player).

And I'm not sure how you think a text file is "hard to read and write"...? Just use the File.ReadAllText method to read the file into a string, and then use its corresponding method, File.WriteAllText(), to write the text back to the file.

more ▼

answered May 24 '10 at 09:33 PM

qJake gravatar image

qJake
11.6k 43 78 161

Thanks for the reference.

I mean hard to read and write because when I read a text file I have a large string.. and then? How can I read informations from that? (Like splitting the string in thousand parts)

May 24 '10 at 09:38 PM Tobias

That's called string parsing, and everyone has their own way of doing it. You need to devise a protocol or something that you can use to read and write the data to/from your text file. There isn't a "right" way to do it, you just have to do it your own way.

May 24 '10 at 10:01 PM qJake
(comments are locked)
10|3000 characters needed characters left

What is a trading card game without opponents? Where do opponents come from if not the internet, Do yourself a favor and learn / setup the MySQL database now. You don't have to buy one from the internet or anything, just run one locally using an easy web host kit like XAMPP or WAMP.

MySQL isn't as complex as it seems.

more ▼

answered May 25 '10 at 02:20 AM

Adrian Love gravatar image

Adrian Love
228 4 6 18

First I was thinking about LAN/Single Player.

I dont have problems with MySQL I know how to set it up, creating database and tables and optimize them.

But I have problems with connecting Unity to the MySQL Database.

Anyway thanks for you reply

May 25 '10 at 06:23 AM Tobias

Hey man, that's cool. It sounds like it could be done really well with some love, be sure to advertise if you get something together.

May 25 '10 at 06:47 AM Adrian Love

Hehe I hope so Adrian. Ive just got mysql connection working :D I forgot to add the mysql dll to unity.

May 25 '10 at 07:13 AM Tobias
(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:

x5272
x442
x241

asked: May 24 '10 at 09:25 PM

Seen: 1990 times

Last Updated: May 24 '10 at 09:25 PM