I have this problem: I try to save the current status of a game I'm developing, and this "progress" is written in a Texture2D. Think of it like a MS Paint canvas where you draw things, only it's not :) Even after doing as I was told looking in other answers around here, the final save file is around 1kb, when it should be around 3MB (the texture is quite large).
Here's my code:
That's only a sample, it's actually bigger but that's the part that's failing, I'm quite sure of that. For more information, right now I'm getting this error:
Excepcion al serializar el savegame. Datos: Type UnityEngine.Texture2D is not marked as Serializable.
This is captured in this "try":
...while saving in the method Save.
I've read (here) that Texture2D is a Serializable type of object, so this is weird to me... I'm using unity 3.4, windows 7 x64 and this is written in c#, but the script that makes the call to "Save" and "Load" functions is in JS.
Any insight in this please? Any help would be GREATLY appreciated!
Finally I solved the problem... It turns out you can't serialize Texture2D (even if it's supposed to work), or at least you can't do it that way. I surrendered and did it with a float array with the color values of the pixels and it all worked out with the same code.
So you know it now, don't serialize Texture2D :D
Maybe you can try again with
which return byte and serialize that.
answered Jul 18 '12 at 09:52 PM