Problem with saving ScriptableObject.

Discussion and help for Easy Save 3
Post Reply
Drandy007
Posts: 3
Joined: Sat Feb 19, 2022 12:40 am

Problem with saving ScriptableObject.

Post by Drandy007 »

I'm trying to create a save system using EasySave3. I've got it to save when the variable (ScriptableObject data type) is set in the Inspector but, I need to create an instance of the scriptableobject at runtime, so can't be set in Inspector. It keeps coming up with

ArgumentNullException: Value cannot be null.
Parameter name: s
System.Convert.FromBase64String (System.String s) (at <695d1cc93cca45069c528c15c9fdd749>:0)
ES3Internal.ES3JSONReader.Read_byteArray () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:561)
ES3Types.ES3Type_byteArray.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Primitive Types/ES3Type_byteArray.cs:24)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:272)
ES3Types.ES3Type.ReadProperties (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3Type.cs:155)
ES3Types.ES3ReflectedValueType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Reflected Types/ES3ReflectedValueType.cs:30)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:249)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:278)
ES3Types.ES3Type.ReadProperties (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3Type.cs:155)
ES3Types.ES3ReflectedScriptableObjectType.ReadScriptableObject[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/Reflected Types/ES3ReflectedScriptableObjectType.cs:24)
ES3Types.ES3ScriptableObjectType.ReadObject[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ScriptableObjectType.cs:69)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:54)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:47)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:249)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:278)
ES3Reader.Read[T] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:197)
ES3.Load[T] (System.String key, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:391)
ES3.Load (System.String key, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:348)
RPG.PlayerSystem.FirstPersonController.RestoreState () (at Assets/Project(Saving)/Scripts/Player/FirstPersonController.cs:64)
RPG.SavingSystem.SaveableEntity.RestoreState () (at Assets/Project(Saving)/Scripts/Saving/SaveableEntity.cs:33)
RPG.SavingSystem.SaveManager.Load () (at Assets/Project(Saving)/Scripts/Saving/SaveManager.cs:70)
RPG.SavingSystem.SaveManager.Update () (at Assets/Project(Saving)/Scripts/Saving/SaveManager.cs:53)

See attached image for code used. Is there a way to get it to work?

EDIT: I wasn't able to add all the snapshots that I took of the code so, here is some of the code I use.

Code: Select all

[SerializeField, ReadOnly]
private BaseState _currentState;
[SerializeField]
private IdleState _idleState;
[SerializeField]
private InteractState _interactState;

private void Start()
{
        #region FSM
        _idleState = ScriptableObject.CreateInstance<IdleState>();
        _interactState = ScriptableObject.CreateInstance<InteractState>();
        TransitionToState(_interactState);
	#endregion
}
Attachments
IdleState.PNG
IdleState.PNG (27.97 KiB) Viewed 981 times
BaseState.PNG
BaseState.PNG (21.58 KiB) Viewed 981 times
Saving.PNG
Saving.PNG (35.59 KiB) Viewed 986 times
Last edited by Drandy007 on Mon Feb 21, 2022 2:40 am, edited 2 times in total.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with saving ScriptableObject.

Post by Joel »

Hi there,

Please could you provide me with information on the ScriptableObject you’re saving.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Drandy007
Posts: 3
Joined: Sat Feb 19, 2022 12:40 am

Re: Problem with saving ScriptableObject.

Post by Drandy007 »

Joel wrote: Sun Feb 20, 2022 10:32 pm Hi there,

Please could you provide me with information on the ScriptableObject you’re saving.

All the best,
Joel
Have updated the post with request info.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with saving ScriptableObject.

Post by Joel »

Hi there,

Unfortunately I’m not able to replicate this from what you’ve sent.

First I would recommend you deleting any existing save data to see if this resolves the issue (Tools > Easy Save 3 > Clear PersistentDataPath).

If this doesn’t resolve the issue, please could you replicate it in a new, minimal project with a simple scene and private message it to me with instructions so I can see what is happening.

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