Page 1 of 1

Loading Sprite Reference from File not Working

Posted: Thu May 13, 2021 8:27 pm
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.

Re: Loading Sprite Reference from File not Working

Posted: Fri May 14, 2021 9:20 am
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