- Home /
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
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 1$$anonymous$$b memory limit in web apps: http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.html
Answer by qJake · May 24, 2010 at 09:33 PM
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.
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)
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.
Answer by Adrian Love · May 25, 2010 at 02:20 AM
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.
First I was thinking about LAN/Single Player.
I dont have problems with $$anonymous$$ySQL I know how to set it up, creating database and tables and optimize them.
But I have problems with connecting Unity to the $$anonymous$$ySQL Database.
Anyway thanks for you reply
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.
Hehe I hope so Adrian. Ive just got mysql connection working :D I forgot to add the mysql dll to unity.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Setting a mesh's triangles and vertices from file causes distortion. 2 Answers
Playerprefs behaviour in unity3.5 0 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer