|
I am trying to save a Javascript array of string Arrays. I need to save this every time I do work in the game. So it looks like serialization is the best method, short of going through a massive for loop and using ArrayPrefs2 on every single damn array. So this serialization thing, seems like a smart way to do it. I have three questions.
(comments are locked)
|
|
You can use BinaryFormatter to store 2D arrays - I presume you want your array stored in a string for this example: No http:// in the http://System.IO line - I can't stop it inserting it! If you want generic level serialization then you can also have a go with the Unity Serializer on my blog
Jun 08 '12 at 07:28 AM
whydoidoit
I'm only trying to save an array in an object, and not entire objects, so I am going to go with your first answer for now(minus the "http://"). As to the first answer I have two questions. First what library does Convert.FromBase64String() come from? I looked for System.Convert but Unity is having none of it. Second is it safe to assume that you would have PlayerPrefs.SetString("total", data); after var data = Convert.ToBase64String(o.GetBuffer()); //Convert the data to a string then have a var data = PlayerPrefs.GetString("total"); before var ins = new MemoryStream(Convert.FromBase64String(data)); //Create an input stream from the string?
Jun 10 '12 at 03:21 AM
easilyBaffled
Convert - I'm thinking that is System? Yep - checked [System.Convert.FromBase64String](http://msdn.microsoft.com/en-us/library/system.convert.frombase64string(v=vs.80).aspx) Those other assumptions are dead right
Jun 10 '12 at 03:38 AM
whydoidoit
Good to know I'm going somewhere now, but when import System.Convert; it throws Unknown identifier: 'Convert'. at me, when using Convert.FromBase64String.
Jun 10 '12 at 01:43 PM
easilyBaffled
Not sure what's so difficult about writing
Jun 10 '12 at 03:01 PM
syclamoth
(comments are locked)
|
|
See http://unity3d.com/support/documentation/ScriptReference/SerializeField From memory you can serialize a 2D array. If that doesn't work for you, store it as a 1D array.
(comments are locked)
|
