Loading Sprite Reference from File not Working

Discussion and help for Easy Save 3
Post Reply
ShaunBartoo
Posts: 5
Joined: Wed May 05, 2021 11:09 pm

Loading Sprite Reference from File not Working

Post by ShaunBartoo »

Hi,

I'm hoping to get some support on an issue I'm having. I'm trying to save a scriptable object called CardData with ES3. One of the fields in CardData is CardImage, a reference to a Sprite. When I save CardData to Cache and then reload it within the same scene, CardImage loads back with the correct reference, but if I try to load CardData saved in a file from a previous session into a scene, the CardImage sprite is null.

Do you have any suggestions for how to save a reference to a sprite such that it will load properly in a later session?

Thanks,
Shaun

Update: I resolved this issue myself by replacing the Sprite reference with an Addressables AssetReference, which I was pleasantly surprised to find serialized perfectly with ES3 after creating a user type for it. As a side benefit, it seems like loading Sprites Async with Addressables might have sped my game up a tad too.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading Sprite Reference from File not Working

Post by Joel »

Hi there,

Glad you managed to resolve your issue. This issue would be because Unity creates a copy of the Sprite in certain situations, a reference to which will no longer exist between sessions. Your use of addressables seems to have circumvented this :)

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