- Home /
What do you say the best way to store a string be?
Let your inner imagination show: I'm not wanting answers such as, "look up PlayerPrefs." or "look at this tutorial." I'm asking if any of you guys would be willing to provide me with any magically delicious method that comes to your special little minds to store a user's data as a string.
The user can have a primary, secondary, grenades, equipment slot 1, equipment slot 2, money, then level.
It has to be a string. Anyone have an amazingly radical method to store this data into a string? String.Split() would be preferred too. Something like 2.3.74.4.6.8.2.673568356.6753 where each blank means something.
Thanks, and stay special
!
Okay, with X$$anonymous$$L, how would I be able to format that?
You could serialize and save an entire "player" or "player data" class, and read that back in at load.
I don't fully understand your needs. If you need your string in a specific format, you may just want to write your own parser
I'm not asking for something that you would give an anwer, I'm asking you guys to let your inner imagination prosper. Give me a format that you would suggest similar to what I put.
Answer by drudiverse · Jul 07, 2014 at 04:16 PM
primary, secondary, grenades, equipment slot 1, equipment slot 2, money, then level.
all code is a string.
You can do like the method that you suggested, but it's more difficult than using an int array.
if you store savegames like
var saveints [2,3,74,4,6,8,2,673568356,6753]
the only difference is a comma instead of a dot
then access it alot easier than with string parse.
when load, grenated = saveints[1] level = savints[2] etc... so easy. play prefs arrays using the wiki playprefs extension.
there are other ways of saving data than playprefs but it is pretty simple.
Answer by Kiwasi · Jul 07, 2014 at 07:45 PM
If you want a obfuscated string then you can serialise a class, convert it to a byte[], then convert it to a string. That string can be saved anywhere you like.
You can even chain several classes together, as long as you insert some defined term in between that you can use to split on.
Your answer
Follow this Question
Related Questions
String.Split With Backslash 2 Answers
how can i split a word to individual letters..?? 2 Answers
Extract number from string? 3 Answers
Split String into groups of characters without using delimiters 1 Answer
How do I connect to an Oracle Database? 6 Answers