i had same project run under unity 5 . and had no errors after upgrading to unity 2019 cause i buy an asset that need to run under unity 2019 i had error in my project after run this was most important error with loading and saving file : the error: Type 'Photon.Realtime.RoomInfo' in Assembly 'PhotonRealtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable. System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers (System.RuntimeType type) (at <7d97106330684add86d080ecf65bfe69>:0) System.Runtime.Serialization.FormatterServices+<>c__DisplayClass9_0.<GetSerializableMembers>b__0 (System.Runtime.Serialization.MemberHolder _) (at..... my code : Code (CSharp): public void Load_Room() { File_Were_Loaded = true; if (File.Exists(Application.persistentDataPath + "/GN3.dat")) { Debug.Log("1"); BinaryFormatter bf = new BinaryFormatter(); Debug.Log("2"); FileStream file = File.Open(Application.persistentDataPath + "/GN3.dat", FileMode.Open); Debug.Log("3"); if (file != null) { First_Connection.MC = (My_Class)bf.Deserialize(file); Debug.Log("4"); file.Close(); Debug.Log("5"); Fill_Rooms(); Debug.Log("Rooms Were Loaded Successfuly !"); //PhotonNetwork.JoinLobby(TypedLobby.Default); } } else { Go_To_Rooms_Screen(); } } public static void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/GN3.dat"); bf.Serialize(file, MC); file.Close(); } //my Saved Classes : using Photon.Realtime; using System; using System.Collections.Generic; using UnityEngine; [Serializable] public class My_Class { public Last_Join_Info last_join_info; public List<_RoomsList> Rooms; //public Player player; public Player_Information PI; public List<RoomInfo> rooms; public string[] Password_For_Rooms=new string[50]; public bool Joined_RG5 ; } [Serializable] public class Last_Join_Info { public string Room_Name=""; public int Room_Size=0; //public string Player_Name=""; public bool Had_Enter_A_Room = false; } [Serializable] public class _RoomsList { public string RoomName; public string RoomPassword; public string RoomConfirmCode; public int RoomSize; public int Room_Coast_Per_one; public int Room_Secret_Number; public int Room_Ws_Deleted=0; //public byte[] Serialize() //{ // Debug.Log("1"); // byte[] roomNameBytes = RoomHolderAndSnderThingy.EncodeString(RoomName); // byte[] passwordBytes = RoomHolderAndSnderThingy.EncodeString(RoomPassword); // byte[] confirmBytes = RoomHolderAndSnderThingy.EncodeString(RoomConfirmCode); // byte[] serialized = new byte[roomNameBytes.Length + passwordBytes.Length+ confirmBytes.Length + 16]; // Debug.Log("2"); // int location = 0; // Array.Copy(roomNameBytes, 0, serialized, location, roomNameBytes.Length); // location += roomNameBytes.Length; // Array.Copy(passwordBytes, 0, serialized, location, passwordBytes.Length); // location += passwordBytes.Length; // Array.Copy(confirmBytes, 0, serialized, location, confirmBytes.Length); // location += confirmBytes.Length; // Array.Copy(BitConverter.GetBytes(RoomSize), 0, serialized, location, 4); // Array.Copy(BitConverter.GetBytes(Room_Coast_Per_one), 0, serialized, location, 4); // Array.Copy(BitConverter.GetBytes(Room_Secret_Number), 0, serialized, location, 4); // Array.Copy(BitConverter.GetBytes(Room_Ws_Deleted), 0, serialized, location, 4); // location += 4; // return serialized; //} //public int Deserialize(byte[] serialized, int startLocation) //{ // int location = startLocation; // int lengthOfString = 0; // Debug.Log("3"); // RoomName = RoomHolderAndSnderThingy.DecodeString(serialized, out lengthOfString, location); // location += lengthOfString; // RoomPassword = RoomHolderAndSnderThingy.DecodeString(serialized, out lengthOfString, location); // location += lengthOfString; // RoomConfirmCode = RoomHolderAndSnderThingy.DecodeString(serialized, out lengthOfString, location); // location += lengthOfString; // RoomSize = BitConverter.ToInt32(serialized, location); // Room_Coast_Per_one = BitConverter.ToInt32(serialized, location); // Room_Secret_Number = BitConverter.ToInt32(serialized, location); // Room_Ws_Deleted = BitConverter.ToInt32(serialized, location); // location += 4; // return location - startLocation; //} } [Serializable] public class Player_Information { public string Player_Name; public string Password_Entered_For_Last_Room; public string Last_Room_Joined_Name; public bool Player_Is_Active; public int Player_Secret_Number; }
I'm not positive this will have any impact, but try the generic version for the above, if it exists: Code (csharp): First_Connection.MC = bf.Deserialize<My_Class>(file); Caution: I have no idea if it exists, but give it a try.
Alas the world does change over time, especially software. You may need to upgrade the module that contains that 'Photon.Realtime.RoomInfo' class. Alternately if you have the source for that class, you might be able to add extra decoration (such as Serializable) to make the binary formatter happy. Or there might be other hints you can give the binary formatter, but I haven't used that construct at all myself. Might just need some more googling: it is almost a certainty that you're not the first person to encounter this exact error.