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
And I add it to the list
When I quit the game and hit play again and call the load function I lose the reference to the object in the assets.
Any help with this problem. I really can't figure out how I can fix this.
Saving a list that contains a scriptable object breaks the reference of the actual object
-
- 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
- Attachments
-
- Screenshot 2021-04-07 194953.png (3.55 KiB) Viewed 904 times
Re: Saving a list that contains a scriptable object breaks the reference of the actual object
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
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
-
- 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
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