I need to use PlayerPrefs to store arrays of bytes for my game. For some reason, the string I save with PlayerPrefs doesn't come out with the same length.
I.e.
byte[] TestArray = new byte[256];
for (byte i = 0; i < 256; i++)
{
TestArray[i] = i;
}
char[] charBuffer = new char[TestArray.Length];
for (int i = 0; i < TestArray.Length; i++)
{
charBuffer[i] = (char)TestArray[i];
}
PlayerPrefs.SetString ("Storage", new string(charBuffer));
PlayerPrefs.Save ();
Debug.Log (new String(charBuffer).Length);
Debug.Log (PlayerPrefs.GetString ("Storage").Length);
Log:
256
5
Is this possibly an issue with encoding? How do I fix it?