Save ScriptableObject fields?

Discussion and help for Easy Save 3
Post Reply
gill_82
Posts: 2
Joined: Tue Mar 24, 2020 4:30 pm

Save ScriptableObject fields?

Post by gill_82 »

Firstly,

great program; has been very useful to me.

But, I've tried Saving/Loading SOs that contain a SO field, and that field data doesn't Save/Load. Is it possible to do?


Eg:
public void MySO : ScriptableObject
{

public OtherSO otherSO;

}

MySO instance saves, but otherSO data is null on Load.
User avatar
Joel
Moodkie Staff
Posts: 4825
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save ScriptableObject fields?

Post by Joel »

Hi there,

Fields of UnityEngine.Object types (such as ScriptableObjects) are saved by reference, so this indicates that a reference to that ScriptableObject no longer exists (perhaps because it's created at runtime). Are you getting a warning in console saying that a reference is missing?

In this case you should also have a separate save call to save any ScriptableObjects which might need to be loaded by reference. For example every time you create an instance of a ScriptableObject you could add it to a List and save this. And then before loading anything which may reference these ScriptableObjects, load this List.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
gill_82
Posts: 2
Joined: Tue Mar 24, 2020 4:30 pm

Re: Save ScriptableObject fields?

Post by gill_82 »

Ok, no problem.

Thanks
Post Reply