Question regarding component serialization

Discussion and help for Easy Save 3
Post Reply
CitrioN
Posts: 6
Joined: Wed Mar 02, 2022 3:33 pm

Question regarding component serialization

Post by CitrioN »

Hello,

I am trying to modify the ES3Type_GameObject script to make a property for each component individually instead of the default list.
My problem I believe is not getting the __type serialized like in the components list.
This is what I you get when serializing as a list. Notice the __type field.

Code: Select all

"components" : [
	{
		"__type" : "Transform",
		"_ES3Ref" : "2870870594340260248",
		"goID" : "753098917395072515",
		"parent" : null,
When I use

Code: Select all

writer.WriteProperty($"component_{index}", component, ES3.ReferenceMode.ByRefAndValue);
I get the following:

Code: Select all

		
"component_1" : {
	"_ES3Ref" : "2870870594340260248",
	"goID" : "753098917395072515",
	"parent" : null,
Notice how there is no __type field.

My question is how would I do that because LoadInto does not seem to work for me with what is serialized with my current code.
When the reader gets to the component_1 property it throws the following error

Code: Select all

FormatException: Expected ',' separating properties or '"' before property name, found '{'.
when I try to read it with

Code: Select all

ES3TypeMgr.GetOrCreateES3Type(type).ReadInto<Component>(reader, component);
I looked through all the code how it is done for the list of components but I can't figure out what the problem with my code is.

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

Re: Question regarding component serialization

Post by Joel »

Hi there,

I don’t appear to be able to replicate this at my end. Please could you create a new project with a very simple scene which replicates this and private message it to me with instructions.

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