I’m delving into the exciting world of serializing and saving things for the first time and running into a frustrating issues. I have serialized classes that I’m saving out using standard json methods and some of the variables in those classes are Images. Somewhat to my surprise, saving and loading those worked since what I assume to be the local resource ID is being properly serialized and deserialized. Unfortunately, these saves are corrupted whenever I change the game’s build, presumably because the local ids of the images are being reinitialized under the hood. My next step to prevent this issue would be to stop assigning Images and start assigning manual index references to some Image-Library master script, but that seems like exactly the sort of thing the engine should be doing for me. Is there a way to tell Unity to stop changing resource IDs once assigned, or some similar solution to this problem?
What are you referring to with “local resource ID” and “chane the game’s build”?
Anyway, you should be able to work with the asset GUIDs, since they should not change unless the assets are moved in Finder/Explorer/etc.
What I mean is that when I serialize and export to JSON I get things like: “CombatSprite”:{“instanceID”:10632} And then when I re-serialize it, it points to the correct image. But when I rebuild the project (Build&Run) all those instanceID’s now point to nothing and all my images are blank
It sounds like maybe my best option is to write a translation layer that uses the GUID.
Where are the images stored?
Just inside Assets/Textures