Unfortunately the included Save() and Load() methods are not able to save/load Unity Object references. That is because the Save() and Load() methods save the data to json and then save that json to Unity PlayerPrefs. However, both json only and especially PlayerPrefs are incapable of including the required data for a Unity Object reference. This is why json serialization for Unity Objects always comes in pair with a List(UnityEngine.Object) within which the references are stored. The json, being a string, only holds the index of the reference within that list.
Is your goal to Save and Load the variables for the current game session, or to Save and Load the variables between gaming sessions (like a Save Game system) ?
Thank you!
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.