- Home /
Does serialization save references?
Hi folks,
As written here unity will serialize every object individually and it won't keep references. Example:
string str1 = "string 1";
string str2 = str1;
... do serialization stuff with a binary formatter
If that is true, then in the saved format (I save to a file called test.dat) I should see the string "string 1" two times, but when i look at the file with a hex editor I get this:
(The serialized class is called Mineral and it has the fields name, value, str1 and str2) I created two objects from that class one has the name set to "Mineral 1" and the other to "Mineral 2". The interesting thing is that there is only one string "string 1" in the whole file. If Unity didn't save references it should be there 4 times (twice for every object).
Now I wonder, does Unity's serialization save references, meaning that the article above is too old and just wrong?
I need to know this, because I can't get ScriptedObjects to work, because they "are not market for serialization"... But that's not of importance right now.