Scriptable objects for store data.

I have doubts about scriptableObjects.
I’m an old Unity user (since Unity 3) and some (relatively new) features I’ve never used.

The most talked about feature is saving persistent data to an object. As an ever persistent script.
I have read several tutorials on the subject but there is one thing I did not understand.

How can you use this functionality if the original object variables are changed?
If I had multiple saves (like the classic saving slots) how can a scriptableObject work for this function if the object being modified is the original one?

If for example I have an inventory that uses a scriptable object to be persistent, what if I want to open a save other than the last one?
Or if you want to start a new game? If the original file has been modified, would I have the data of the last state of the scriptable object?

It’s better for saving editor scripts, such as the post processing profiles. If you are trying to use it like a save game, then there is only one scriptable object. You can use ScriptableObject.CreateInstance, but this is just the same as using a regular C# class instance.

2 Likes

ScriptableObjects aren’t persistent. Only in the Editor.
When you make a build, run your game, change something in the ScriptableObject, exit the game and restart it, it won’t retain the change.
You still need a proper save system to achieve persistence.

SOs are persistent between scenes though given their asset nature.

8 Likes

See scriptable objects as data blueprints that you then create instances of at runtime. Much like prefabs but without the need of having a transform in the scene

My scriptable objects are always saying it cant be loaded

Thanks to all of the answers! I go back to my old serialization system. :wink:

1 Like

This really gave me some ideas on how to use Scriptable Objects properly. Especially when he talks about the Tanks demo at about 36:00