I’d like to save and load data from Scriptable Object.
If there was only strings, ints and floats in this Scriptable Object, I’d use "JsonUtility.ToJson" for saving and "JsonUtility.FromJsonOverwrite" for loading*.* This works flawlessly.
But there are also references to AudioClips, GameObjects and Sprites:
All those are lost when I’m trying to load them on a build.
Do you know a simple way of saving and loading data for Scriptable Objects.
Long story short, you can’t easily serialise out references to other Unity objects.
You’re always going to have to substitute them with different data in some way. This can easily be done with a ‘serialisable surrogate’, ergo, an object that takes in your runtime data and replaces it with basic data that you can serialise out. Then you use this surrogate on load to restore any Unity object references in the runtime version (such as loading from Addressables, Resources or your own rudimentary database).
I recommend learning to use more robust serialisers such as Newtonsoft.JSON or the Odin serialiser as well.