I'm getting errors when trying to build for Windows 8 WP8 regarding serialization Code (csharp): "The type or namespace name 'ISerializable" could not be found..." "The type or namespace name 'Formatters" could not be found.." "The type or namespace name 'SerializationInfo" could not be found..." Is this not supported in Unity Windows/Phone 8 or is something wrong?
Could you tell me how to solve it?If my project has a lot of "ISerializable" and "Serializable",may I must to change my Code?
It depends whether you use it for serialization or just have such attributes on classes. In the later case you can wrap those attributes with #if UNITY_METRO.
Aurimas is right, you'll need to wrap those to hide them from the build. It's done in my JSON .NET asset for serialization, but you can also look at the original JSON .NET source code as a reference: http://json.codeplex.com/ Download the source package and take a look at what JNK did for Windows Phone and WinRT.
It also report "Error: type `System.Runtime.Serialization.SerializationInfo` doesn't exist in target framework. ",
Hello,because i use xml to save my scene,many problem show while build.The JSON.NET can simplily change it to json.If can ,how to do it?Thankes a lot!
John - It won't automatically convert your XML to JSON if that's what you're asking but if you did want to use my asset you won't need the Serialization attributes. You can use them, but not necessary. For instance, if you have a class called "Person" and an instance of it in the variable "mainPerson" you would serialize and deserialize as follows: Code (csharp): //create new person instance Person mainPerson = new Person(); //serialize it. string serialized = JsonConvert.SerializeObject(mainPerson); //deserialize an already serialized person Person newPerson = JsonConvert.DeserializeObject<Person>(serialized); Bear in mind though that some things (like MonoBehaviors) can't be automatically serialized because you'll get issues for properties like rigidbody if one isn't assigned. Texture2D is another one that can cause issues because of the lack of a public parameterless constructor that will work with JSON .NET so you'll have to create custom serialization binders or proxy types.