Nested Class Help

Discussion and help for Easy Save 3
Post Reply
RonDMC
Posts: 7
Joined: Thu Nov 23, 2017 12:56 am

Nested Class Help

Post by RonDMC »

I'm not generally a programmer so forgive me if I'm using terms wrong or get easily confused. I try though.

Anyway, I have a serialized nested class with parameters and if I'm reading the documentation right, it's possible to save/load from them but I have to create a custom type for it and modify it. I found it in the Type list and created the automatic script, but now I'm lost. The type window is giving me the error "This type has no public parameterless constructors. To support this type you will need to modify the ES3Type script to use a specific constructor instead of the parameterless constructor." Only problem is, I don't know how to do so.

The class in question has variables that are supported (bools, an int, a string and an enum) so maybe I'm wrong in assuming this can be done or I'm missing the next step.

Any help or guidance would be appreciated.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Nested Class Help

Post by Joel »

Hi there,

Actually the easiest way to fix this would be to add a parameterless constructor to your class. i.e.
public MyClass(){
}
This allows Easy Save to create an instance of your class, and then it should be supported without having to create an ES3Type. Note you will need to delete the ES3Type you previously creates from the Types pane.

If you send me the class you're trying to save (and it's parent class), I'll check that this is the case.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
RonDMC
Posts: 7
Joined: Thu Nov 23, 2017 12:56 am

Re: Nested Class Help

Post by RonDMC »

Nope, that worked. I was over thinking it. Thank you very much!

One thing that happened you might want to know, and this might be more of a Unity issue than an Easy Save issue. I stopped working on the old bad ES3Type while it had a compiler error (I was going to come back to it later) and when I reopened Unity, all of my imported assets and scripts didn't work. Deleting the bad ES3Type script fixed the issue, but it threw me for a scare and I tried reimporting assets and deleting my Library folder before realizing what the issue might have been. I don't know if there's a warning I missed or if you want to put a warning somewhere in the documentation/forums but it might help people who accidentally do what I did.

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

Re: Nested Class Help

Post by Joel »

Hi there,

Glad that solved your problem.

With regards to the compiler error, an ES3Type is the same as any other script in Unity, so if it contains any compiler errors you will need to fix it before any other scripts will compile. However, it should show an error in the console saying that it contains errors which require fixing.

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