Can i use tags during ES2 serialization pipline working ?

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
Lordinarius
Posts: 8
Joined: Tue Jun 14, 2016 2:30 pm

Can i use tags during ES2 serialization pipline working ?

Post by Lordinarius »

Hello
I am trying to serialize arrays independend from their index so even when i change index of an item it loads from its ID. Tried it with
using ES2Writer and ES2Reader and it works perfect

But i tried it implementing in ES2Type and got an error

so here is how i am doing it

Code: Select all

public class ES2UserType_VehicleContainer : ES2Type
{
	public override void Write(object obj, ES2Writer writer)
	{
		VehicleContainer data = (VehicleContainer)obj;
		// Add your writer.Write calls here.
        writer.Write(data.unlocked, string.Format("status{0}", data.itemID));
    }
	
	public override object Read(ES2Reader reader)
	{
		VehicleContainer data = new VehicleContainer();
		Read(reader, data);
		return data;
	}

	public override void Read(ES2Reader reader, object c)
	{
		VehicleContainer data = (VehicleContainer)c;
		// Add your reader.Read calls here to read the data into the object.
        data.unlocked = reader.Read<bool>(string.Format("status{0}", data.itemID));
    }
	
	/* ! Don't modify anything below this line ! */
	public ES2UserType_VehicleContainer():base(typeof(VehicleContainer)){}
}
And error :

Code: Select all

Exception caught while invoking the method named SaveL from an inspector button. The exception was "Easy Save 2 Error: The file provided does not contain data that is readable by Easy Save. Please make sure that file was created by Easy Save." and the stack was "  at ES2Reader.Next () [0x00000] in <filename unknown>:0 
  at ES2Reader.DeleteTags (ICollection`1 tags, .ES2Writer writer) [0x00000] in <filename unknown>:0 
  at ES2Writer.Delete () [0x00000] in <filename unknown>:0 
  at ES2Writer.Save (Boolean checkForOverwrite) [0x00000] in <filename unknown>:0 
  at ES2Writer.Save () [0x00000] in <filename unknown>:0 
  at ES2.Save[ListItemSerializationTest] (.ListItemSerializationTest[] param, System.String identifier) [0x00000] in <filename unknown>:0 
  at VehicleManager.SaveL () [0x0000c] in C:\Users\med_c\Documents\gitrepos\blocky_dev_project\blockypursuit\Assets\BPFiles\Scripts\Game\VehicleManager.cs:71 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
.
.
.
.
.
Lordinarius
Posts: 8
Joined: Tue Jun 14, 2016 2:30 pm

Re: Can i use tags during ES2 serialization pipline working

Post by Lordinarius »

I made a search in the forum. Now i understand that i can't do that. During ES2Type read write Sequential reading needed :)
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Can i use tags during ES2 serialization pipline working

Post by Joel »

Lordinarius wrote:I made a search in the forum. Now i understand that i can't do that. During ES2Type read write Sequential reading needed :)
This is indeed the case. Glad you managed to find a solution to your problem :)

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