Exception thrown when reading ES3UserType_xxx with an enum variable

Discussion and help for Easy Save 3
Post Reply
caka99
Posts: 2
Joined: Sat Jul 17, 2021 3:07 pm

Exception thrown when reading ES3UserType_xxx with an enum variable

Post by caka99 »

The exception:
[Exception] FormatException: Input string was not in a correct format.
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.

ES3JSONReader.Read_int() at /Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:549
-->549: internal override int Read_int(){ return int.Parse(GetValueString()); }

ES3Type_enum.Read[T]() at /Plugins/Easy Save 3/Scripts/Types/Primitive Types/ES3Type_enum.cs:42
-->42: if(underlyingType == typeof(int)) return Enum.ToObject (type, reader.Read_int());
I have to change enum to int:
Write:

Code: Select all

		protected override void WriteComponent(object obj, ES3Writer writer)
		{
			var instance = (NaAGames.Humanoid)obj;

			//writer.WriteProperty("humanoidState", instance.humanoidState, ES3Internal.ES3TypeMgr.GetES3Type(typeof(NaAGames.HumanoidState)));
			writer.WriteProperty("humanoidState", instance.humanoidState, ES3Type_int.Instance);
		}
Read:

Code: Select all

		protected override void ReadComponent<T>(ES3Reader reader, object obj)
		{
			var instance = (NaAGames.Humanoid)obj;
			foreach(string propertyName in reader.Properties)
			{
				switch(propertyName)
				{
					
					case "humanoidState":
						//instance.humanoidState = reader.Read<NaAGames.HumanoidState>();
						instance.humanoidState = (NaAGames.HumanoidState)reader.Read<System.Int32>(ES3Type_int.Instance);
						break;
				}
			}
		}
	}
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Exception thrown when reading ES3UserType_xxx with an enum variable

Post by Joel »

Hi there,

Thanks for sending that over. I've managed to replicate this at my end and will ensure this is resolved in the next update.

If you could also remove the support request from the reviews section of the Asset Store that would also be greatly appreciated.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
caka99
Posts: 2
Joined: Sat Jul 17, 2021 3:07 pm

Re: Exception thrown when reading ES3UserType_xxx with an enum variable

Post by caka99 »

Thanks!
Ok!
tarlan83
Posts: 3
Joined: Mon Jul 26, 2021 5:57 am

Re: Exception thrown when reading ES3UserType_xxx with an enum variable

Post by tarlan83 »

And when do you intend to release the new version, since I have the same problem?! :(

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

Re: Exception thrown when reading ES3UserType_xxx with an enum variable

Post by Joel »

Hi there,

This version is now live on the Asset Store, so updating and deleting your previous save data should resolve the issue.

If it doesn't, if you private message me your invoice number I'll send over the update directly as it may be that the Asset Store is failing to update.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
hassan121
Posts: 5
Joined: Fri Sep 03, 2021 8:10 am

Re: Exception thrown when reading ES3UserType_xxx with an enum variable

Post by hassan121 »

Hi Joel, I am updating the package but it is still does'nt seem to fix the issue. I am still having issue with enums.

FormatException: Input string was not in a correct format.
System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Int32.Parse (System.String s) (at <9577ac7a62ef43179789031239ba8798>:0)
ES3Internal.ES3JSONReader.Read_int () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:549)
ES3Types.ES3Type_enum.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Primitive Types/ES3Type_enum.cs:42)
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Exception thrown when reading ES3UserType_xxx with an enum variable

Post by Joel »

Hi there,

Have you deleted your previous save data?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
hassan121
Posts: 5
Joined: Fri Sep 03, 2021 8:10 am

Re: Exception thrown when reading ES3UserType_xxx with an enum variable

Post by hassan121 »

Yes, I have deleted everything and tried multiple times. It never works with enums.
hassan121
Posts: 5
Joined: Fri Sep 03, 2021 8:10 am

Re: Exception thrown when reading ES3UserType_xxx with an enum variable

Post by hassan121 »

hassan121 wrote: Mon Sep 06, 2021 9:00 am Yes, I have deleted everything and tried multiple times. It never works with enums.
Hi, I found out what the issue was. I mistakenly left ES3 Auto Save component attached to one of the GameObjects which didn't have some scripts components referenced in it. I removed it and the issue was fixed. I was really tough to find out though and I got lucky in finding it.
Post Reply