Hey,
So im in the process of updating my large scale projects to a more recent version of unity. Trying to update projects to the new Unity 2018.3.
-
In the process, it specifies that .NET 3.x is depreciated and therefore I chose to try and update to .NET 4.X. Most of it converted correctly, some issues i've solved but this one is a bit more worrying for me.
----------
I have a system that loads serialized files. The loading is as follows
BinaryFormatter bf = new BinaryFormatter();
string[] files = Directory.GetFiles(Application.dataPath + "/Resources/Structures/Tree");
foreach(string s in files)
{
FileStream file = File.Open(s, FileMode.Open);
Trees.Add((Structure)(bf.Deserialize(file)));
file.Close();
}
The structure class is as follows:
[System.Serializable]
public class Structure
{
public string Name;
public Dictionary Data;
public Structure(string n)
{
Name = n;
Data = new Dictionary();
}
}
This works perfectly in .NET3.x and has done for over a year, so moving to .NET4.x fails on the line 'Trees.Add((Structure)(bf.Deserialize(file)));' giving a Object must implement IConvertible Error.
----------
Making Structure inherit from IConvertable produces a range of errors due to not implementing all the functions of it (i do not want to go through and do these all manually if possible... First off due to effort as this is not the only class that I serialize like this, and also this would then render all previously made serialized files unusable which is a bit no no if possible..
----------
If anyone has any tips or pointers as to what is actually causing this issue or ways to fix it i would greatly appreciate it
↧