Easy Save loading wrong info

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
PabloAM
Posts: 26
Joined: Tue Nov 18, 2014 8:43 pm

Easy Save loading wrong info

Post by PabloAM »

Hello, I don´t know why but EasySave2 is reading wrong data.

I´m saving as (MADNESS):
writer.Write(data.currentMode);

and I´m loading (HORDE, is other mode):
data.currentMode = reader.Read<Globals.GameModeEnum>();

Im following with breakpoints, and the last saved is MADNESS (As it should) :S

Modes:
//Game mode
public enum GameModeEnum
{
Madness,
Horde,
HordeParallel,
FloorIsLava
}

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

Re: Easy Save loading wrong info

Post by Joel »

Hi there,

I can't seem to make sense of what you're doing. Please could you provide me with a test script so I can try to replicate this at my end?

Also please could you let me know the version of Unity you are using.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
PabloAM
Posts: 26
Joined: Tue Nov 18, 2014 8:43 pm

Re: Easy Save loading wrong info

Post by PabloAM »

I found the problem is over here:

Write.Write(1) changes mode to the mode 1...

Code: Select all

public class ES2UserType_GlobalsGameModeEnum : ES2Type
{
	public override void Write(object obj, ES2Writer writer)
	{
		Globals.GameModeEnum data = (Globals.GameModeEnum)obj;

        // Write the version number, which you increment whenever you add fields to the ES2Type.
        writer.Write(1);

        // Add your writer.Write calls here.
        writer.Write((int)data);

	}
	
	public override object Read(ES2Reader reader)
	{
		Globals.GameModeEnum data = (Globals.GameModeEnum)reader.reader.ReadInt32();

        // Read the version number.
        int fileVersion = reader.Read<int>();


        // These are fields we added in version 2. 
        if (fileVersion >= 1)
        {
            //data.vibrate = reader.Read<System.Boolean>();
        }

        return data;
	}
	
	/* ! Don't modify anything below this line ! */
	public ES2UserType_GlobalsGameModeEnum():base(typeof(Globals.GameModeEnum)){}
}
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Easy Save loading wrong info

Post by Joel »

Hi there,

If you're writing an enum as the name suggests, you do not need to create a custom ES2Type; all enums are natively supported.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
PabloAM
Posts: 26
Joined: Tue Nov 18, 2014 8:43 pm

Re: Easy Save loading wrong info

Post by PabloAM »

Yes, Thanks for support.

It has been fixed :)
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Easy Save loading wrong info

Post by Joel »

Ahh glad to hear it. Let me know if you run into any other issues :)

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