Page 3 of 3

Re: Persist Scriptable Objects between scenes

Posted: Mon Oct 19, 2020 5:38 pm
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

Re: Persist Scriptable Objects between scenes

Posted: Tue Oct 20, 2020 7:14 am
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.

Re: Persist Scriptable Objects between scenes

Posted: Tue Oct 20, 2020 7:33 am
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

Re: Persist Scriptable Objects between scenes

Posted: Tue Oct 20, 2020 7:46 am
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!

Re: Persist Scriptable Objects between scenes

Posted: Tue Oct 20, 2020 8:09 am
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