Issues loading a Struct

Discussion and help for Easy Save 3
Post Reply
alexIsCoolYo
Posts: 4
Joined: Mon Feb 14, 2022 3:36 pm

Issues loading a Struct

Post by alexIsCoolYo »

Hello,

I've got an issue where my Structs are saving just fine, but won't load correctly, however the other saved data loads in fine.

So I've got a class that contains some data along with a Struct Array of data. I have both the Struct "EnemySpawnData" And Class "MapZoneSpawnConfig" set to custom ES3 types. The save file for these are saved/loaded from Resources & it saves/loads fine, the for BattleZoneSpawnType, obsticleID, breakZoneType load just fine and the length of each struct array is there but there is no data for each element in the struct.

The data in the struct is just 1 string and 2 int & they show up fine in the .bytes file but don't load & instead the struct data is just left empty.

Save File:

Image

The class that contains all the data:

Image

Below is the ScriptableObject that loads the data, this image shows whats in there after loading and If you match it with the save file in the image above, the save file has the characterID "PurpleMushroom" with min/max spawn of 2 & 4, but the SO below loads nothing other than the length of the array.

Image

Both are setup for custom ES3 Types just fine:

Image

Image

Any help would be great!

Thanks!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues loading a Struct

Post by Joel »

Hi there,

I don’t appear to be able to replicate this. From what you’ve described it sounds like something else is changing the structs after they’ve been loaded.

Please could you replicate this in a new project with a simple scene which just saves and loads the structs without any other logic so the issue can be isolated to Easy Save.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
alexIsCoolYo
Posts: 4
Joined: Mon Feb 14, 2022 3:36 pm

Re: Issues loading a Struct

Post by alexIsCoolYo »

Hay,

Just made a new project & was able to replicate this issue.

Want me to send you the project?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues loading a Struct

Post by Joel »

Yes please. If you zip it and upload it to something or Google Drive or WeTransfer and private message it to me with instructions I’ll take a look.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
alexIsCoolYo
Posts: 4
Joined: Mon Feb 14, 2022 3:36 pm

Re: Issues loading a Struct

Post by alexIsCoolYo »

Please check you DMs, thanks
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues loading a Struct

Post by Joel »

Hi there,

Just a heads-up that we’ve not forgotten about your PM. As support tickets which require us to download a project take much longer to respond to, we have a queue of these to work through (Jan and Feb are the busiest times of the year for us).

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues loading a Struct

Post by Joel »

Hi Alex, and thanks for your patience on this one.

The issue was because of the private property on a struct. This is frowned upon because it uses the struct in a mutable way, causing some very difficult-to-debug issues as a copy of the struct is made every time the setter is called, but this copy is not necessarily accessible elsewhere. In these cases you almost always want to use a class instead, but I trust that you know what you're doing 🙂

Although it's frowned upon, it's still valid syntax, so I've accounted for this when generating ES3Types. If you would like the update which resolves this issue, private message me your invoice number and I'll send it over.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
alexIsCoolYo
Posts: 4
Joined: Mon Feb 14, 2022 3:36 pm

Re: Issues loading a Struct

Post by alexIsCoolYo »

Ah ok, thanks for that. I didn't know that about Struct and I've since updated my struct to use Public fields & this has fixed the issue :)

In no rush for the new update, I assume will come out in an official update at some point.

Thanks for the help and info!
Post Reply