c# - Deserialize a string bytes into BitStream -
c# - Deserialize a string bytes into BitStream -
my problem follows: serialize info , send them playerprefs
bitstream bitstream = new bitstream(istypesafe); bitstream.writebyte(species); bitstream.writeint32(revision); playerprefs.setstring(species.tostring(), bitstream.tostring());
and seek deserialize data:
bitstream bitstream = new bitstream(istypesafe); bitstream.writestring(playerprefs.getstring(species.tostring())); species = bitstream.readbyte(); revision = bitstream.readint32();
but output wrong data. doing wrong?
the fundamental problem here utilize strings storage binary data. wrong because changing string encoding can occur ruin data. unfortunately, playerprefs
doesn't provide way save/load binary data. thus, solution utilize textual serialization instead.
p.s. looks incorrect:
bitstream.writestring(playerprefs.getstring(species.tostring()));
c# unity3d
Comments
Post a Comment