Persist Scriptable Objects between scenes

Discussion and help for Easy Save 3
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Persist Scriptable Objects between scenes

Post by Joel »

Hi there,

I've had no reports of this. Please could you create a new project with a very basic scene which replicates this and private message it to me with instructions?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
JoseHawk
Posts: 25
Joined: Tue Sep 22, 2020 12:51 pm

Re: Persist Scriptable Objects between scenes

Post by JoseHawk »

Morning,

If I am not able to find a solution, I will create the project for you. The problem is that is very time consuming, at this is a project with more than 2 years of development, so it is not straight forward to replicate all the stuff...

Meanwhile, I wanted to let you know one find, so maybe you can see something, as all my problems have been solved with basically clicking in options and no programtically.
- I have a scene with many types of scriptable objects. In development, everything is serialized when saving and loading and works fine. But after generating a build, all of them are corrupted EXCEPT for 2 scriptable objects ("Key Data" class).
- If I add these objects to another scene and I generate a build, these 2 objects are also corrupted.
- There must be something IN THE SCENE that I am missing. I already tried clicking in the "Refresh" button, selecting the objects in the "Easy Save > Auto Save", etc.

Does this situation say something to you?

Thank you in advance.

Cheers.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Persist Scriptable Objects between scenes

Post by Joel »

Hi there,

Just to check, is there a reference to the ScriptableObject in your scene prior to entering Playmode? Also if you're not already, ensure that you're on the latest version of Easy Save.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
JoseHawk
Posts: 25
Joined: Tue Sep 22, 2020 12:51 pm

Re: Persist Scriptable Objects between scenes

Post by JoseHawk »

Hello,

There is a gameObject (Collectable) that has as a parameter, the scriptable object:

Code: Select all

  public class Collectable : MonoBehaviour
    {
        [SerializeField] private CollectableTypeState collectableType;
        [SerializeField] [HideInInspector] private CollectableData collectableData;
        [SerializeField] [HideInInspector] private WeaponData weaponData;
        [SerializeField] [HideInInspector] private ArmorData armorData;
        [SerializeField] [HideInInspector] private BadgeData badgeData;
        [SerializeField] [HideInInspector] private UpgradeData upgradeData;
}
Where the "CollectableData", "WeaponData", "ArmorData", etc. are scriptable objects.

I have as reference the Collectable (a chest in the game) with a reference (See attach), but I am not sure about the scriptable objects inside of it, that are the one that are passed to the Inventory of my Player. How I can make sure that these scriptable objects have their own references? I cannot have scriptable objects in the "Hierarchy".

Thanks!
Attachments
Captura2.PNG
Captura2.PNG (3.74 KiB) Viewed 1271 times
Captura.PNG
Captura.PNG (16.8 KiB) Viewed 1271 times
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Persist Scriptable Objects between scenes

Post by Joel »

Hi there,

This should be enough for Easy Save to be able to find the reference and automatically add it to the manager. Unfortunately I'd need to see a sample project to understand why this is not happening.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply