Saving a list that contains a scriptable object breaks the reference of the actual object

Discussion and help for Easy Save 3
Post Reply
georgetas12345
Posts: 2
Joined: Wed Apr 07, 2021 4:37 pm

Saving a list that contains a scriptable object breaks the reference of the actual object

Post by georgetas12345 »

What I am trying to achieve is pretty complicated. I am trying to save a list that contains scriptable objects. The scriptable objects are created at runtime. Each time I am trying to load the new list in start/awake the load loses the reference to the object in the assets folder.

To show in more detail this is what happens in runtime.
I create a scriptable object in assets
Image

And I add it to the list

Image

When I quit the game and hit play again and call the load function I lose the reference to the object in the assets.

Image

Any help with this problem. I really can't figure out how I can fix this.
Attachments
Screenshot 2021-04-07 194953.png
Screenshot 2021-04-07 194953.png (3.55 KiB) Viewed 856 times
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving a list that contains a scriptable object breaks the reference of the actual object

Post by Joel »

Hi there,

It's not possible to store a reference to an object in the Assets folder which was created at runtime because it wouldn't be possible to resolve a runtime reference to it.

The only alternative would be to create an instance of it (rather than directly referencing it in Assets), and save this reference by value and reference so that this instance can be created and referenced (which looking at your screenshots is what is currently happening).

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
georgetas12345
Posts: 2
Joined: Wed Apr 07, 2021 4:37 pm

Re: Saving a list that contains a scriptable object breaks the reference of the actual object

Post by georgetas12345 »

One thing I forgot to mention is that the variables of the actual object are still there nothing is changing. The only thing that is missing is the reference to the object in the assets folder
Post Reply