How to serialize SO without editor?


So, I’m pretty new to using SO, While trying to use them I noticed that when I entered play mode and exited all the data I had in the SO got reset back to 0s/nulls.

From what I searched, it seems just a problem of the data not being saved.

These answers would work as intended, but lets say I don’t want to save it from the editor or even the original SO, but from a different script.

Is it possible to do?


A scriptable object is something you setup in the editor. You can have multiple SO’s of the same type and they can all have fields with different values and you set those values in the editor. They are just containers to store variations of a data structure which are not editable at runtime through code.

If an object which utilizes an SO at runtime manipulates the data it gets from the SO, it does not change the values of the base SO as you have it setup in the editor. If you want to save the manipulated data, you should do so with the Binary Formatter in the file system, but again, that won’t be the original SO that you are saving, it will be the manipulated data that you are saving.

I personally only use SO’s as containers of data structures that hold predetermined constants and I think this is the right way to think of them. If you don’t know the values beforehand, then you should just use a regular class and save the data as needed, if you were to use an SO in this case it would be pretty useless