Easy Save 2 Error: Expected data of type System.Single

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
maja0270558
Posts: 1
Joined: Wed Mar 29, 2017 4:21 am

Easy Save 2 Error: Expected data of type System.Single

Post by maja0270558 »

like the title.
I got this error,so I write a function to try-catch this error.
But the error still exist.
Here is my function

Code: Select all

    public T TryLoadES2<T>(string tag)
    {
        try
        {
            return (T)Convert.ChangeType(ES2.Load<float>(fullFileName + "?tag=" + tag), typeof(T));
        }
        catch (Exception e)
        {
            return (T)Convert.ChangeType(ES2.Load<int>(fullFileName + "?tag=" + tag), typeof(T));
        }
    }
Did i do something wrong here :| ?
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Easy Save 2 Error: Expected data of type System.Single

Post by Joel »

Hi there,

This error is intentionally thrown using Debug.LogError rather than an a catchable exception to prevent memory leaks.

If you want to load data but are unsure of it's type, you should use ES2.LoadObject instead, and then use object.GetType() on the loaded data to get it's type.

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