Comment on page
Save and Load
You may see a yellow "warning" in the Console about the serialization depth limit being reached.
Yellow "Warnings" in the console are not errors, and do not always mean something is wrong!
This is because the Dictionaries often are already a few levels deep into an object hierarchy, and have a fair number of levels themselves. If you store a
Prefabin the dictionaries which also had a dictionaries, this warning will appear more often.
THIS IS NOT ALWAYS A PROBLEM.
Depending on the project, you may not need to serialize the dictionaries, so "data not saved" is not "data lost".
Keep in mind that the "Dictionaries" on a "Game[TYPE]", such as "GameItemObject", can be changed and saved at runtime. But in many cases, the values needed are stored in the Parent object (such as the "ItemObject" scriptable object), which is not changed at runtime, and is not serialized.
However, if you do wish to serialize the data and the depth is past the limit, there are two methods that can be used to compress the data prior to saving.
LoadData()will deserialize the string back into a dictionaries object, which can be done during the
The JSON data will encode each
KeyValueinto an item of a
List<string>, and then the entire Dictionaries into a string. The data will be decoded from those strings into