ES2_UserType issues reading float

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
JustiNoPot
Posts: 3
Joined: Thu Jan 31, 2019 5:03 pm

ES2_UserType issues reading float

Post by JustiNoPot »

Hi there, I keep receiving the following error:

EndOfStreamException: Failed to read past end of stream.

when trying to load the following UserType:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class ES2UserType_GameData : ES2Type
{
	public override void Write(object obj, ES2Writer writer)
	{
		GameData data = (GameData)obj;
        // Add your writer.Write calls here.

        writer.Write(data.TotalGamePlays);
        writer.Write(data.Coins);
        writer.Write(data.CurrentLevel);
        writer.Write(data.Health);
        writer.Write(data.ArmourOwned);
}
	
	public override object Read(ES2Reader reader)
	{
		GameData data = new GameData();
		Read(reader, data);
		return data;
	}

	public override void Read(ES2Reader reader, object c)
	{
		GameData data = (GameData)c;
		// Add your reader.Read calls here to read the data into the object.
		data.TotalGamePlays = reader.Read<System.Int32>();
		data.Coins = reader.Read<System.Int32>();
                data.CurrentLevel = reader.Read<System.Int32>();
                data.Health = reader.Read<float>();
                data.ArmourOwned = reader.Read<System.Int32>();

        }
	
	/* ! Don't modify anything below this line ! */
	public ES2UserType_GameData():base(typeof(GameData)){}
}
I changed nothing else in the rest of the files. The error happens when I try to run "data.Health = reader.Read<float>();" Any ideas what could be causing my issue?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES2_UserType issues reading float

Post by Joel »

Hi there,

Firstly, please could you go to Assets > Easy Save 2 > Settings > Tools > Open Persistent Data Path, and delete your save data?

If this doesn't fix the issue, please could you PM me a basic project and instructions to replicate this?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
JustiNoPot
Posts: 3
Joined: Thu Jan 31, 2019 5:03 pm

Re: ES2_UserType issues reading float

Post by JustiNoPot »

Thanks that fixed my issue.
Locked