Question about saving Scriptable Objects instead of the name

Hello!!

I was thinking about why are you using Resources folder instead of saving the Scriptable Objects??

I suppose that you just save the name of weapons because the scriptable object doesn’t change its state in runtime, you saved space in the save file and saving/loading times will be faster.

I’m correct or there are another reason too?? I feel like i don’t understand well the lesson and missing something :thinking:

Thank you in advance!!

You can’t simply send a ScriptableObject to the saving system. As complex as it looks, the BinaryFormatter has limitations, and doesn’t serialize MonoBehaviours or ScriptableObjects, which is why we use a Capture/Restore to get the important bits. Unless you’re doing procedural items, you really only need to know which ScriptableObject is the one representing the weapon, so saving the string reference is faster, and significantly easier than trying to save all of the fields in the ScriptableObject.

1 Like

Thanks for the reply!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms