- Home /
webplayer serialize/deserialize error advice plz
Good morning. You are using a version unity3D5.3.3f1 underway webplayer based operations. Files can not be stored in the data processing and webplayer PlayerPrefs the data processing is possible only
public enum TEST_TYPE { None, Test_1 }
[Serializable] public class TestClass { public int nTestint = 0; public bool nTestbool = true;
} [Serializable] public class Test { public string testUser = "User"; public List listTest = new List(); public Dictionary dicTest = new Dictionary();
Test() {
} }
public static void Save() { BinaryFormatter bf = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); Test sTest = new Test (); bf.Serialize(memoryStream, Test); string tmp = System.Convert.ToBase64String(memoryStream.ToArray()); PlayerPrefs.SetString("TEST", tmp); }
public static void Load() { string tmp = PlayerPrefs.GetString("TEST", string.Empty); if (tmp == string.Empty) return; BinaryFormatter bf = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(System.Convert.FromBase64String(tmp)); Test sTest = new Test (); Test = (Test)bf.Deserialize(memoryStream); }
Like the above Serialize / Deserialize the process by working. The unity is the normal data processing. The problem is in the process if you run Deserialize pulled build It causes the following aereo. List, and when annotating Dictionary will be processed. (Write current situation)
FieldAccessException: Attempt to access a private/protected field failed. at System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) [0x00000] in :0 at System.Runtime.Serialization.ObjectRecord.SetMemberValue (System.Runtime.Serialization.ObjectManager manager, System.Reflection.MemberInfo member, System.Object value) [0x00000] in :0 at System.Runtime.Serialization.FixupRecord.FixupImpl (System.Runtime.Serialization.ObjectManager manager) [0x00000] in :0 at System.Runtime.Serialization.BaseFixupRecord.DoFixup (System.Runtime.Serialization.ObjectManager manager, Boolean strict) [0x00000] in :0 at System.Runtime.Serialization.ObjectRecord.DoFixups (Boolean asContainer, System.Runtime.Serialization.ObjectManager manager, Boolean strict) [0x00000] in :0 at System.Runtime.Serialization.ObjectManager.RegisterObjectInternal (System.Object obj, System.Runtime.Serialization.ObjectRecord record) [0x00000] in :0 at System.Runtime.Serialization.ObjectManager.RegisterObject (System.Object obj, Int64 objectID, System.Runtime.Serialization.SerializationInfo info, Int64 idOfContainingObj, System.Reflection.MemberInfo member, System.Int32[] arrayIndex) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject (Int64 objectId, System.Object objectInstance, System.Runtime.Serialization.SerializationInfo info, Int64 parentObjectId, System.Reflection.MemberInfo parentObjectMemeber, System.Int32[] indices) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadValue (System.IO.BinaryReader reader, System.Object parentObject, Int64 parentObjectId, System.Runtime.Serialization.SerializationInfo info, System.Type valueType, System.String fieldName, System.Reflection.MemberInfo memberInfo, System.Int32[] indices) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadGenericArray (System.IO.BinaryReader reader, System.Int64& objectId, System.Object& val) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject (BinaryElement element, System.IO.BinaryReader reader, System.Int64& objectId, System.Object& value, System.Runtime.Serialization.SerializationInfo& info) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject (System.IO.BinaryReader reader) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph (BinaryElement elem, System.IO.BinaryReader reader, Boolean readHeaders, System.Object& result, System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in :0
Reference mosterbank blog http://monsterbank.tistory.com/search/unity web
unity community http://answers.unity3d.com/questions/584269/webplayer-deserialization-fails.html
I saw how the information to be processed or the other side in the Web Play If you are interested, if you like solving minute advice, please, please.
Your answer
Follow this Question
Related Questions
Transferring gameobjects between projects 0 Answers
Create an AssetBundle with prefabs containing imported models 0 Answers
Prefill list with AssetDatabase.LoadAssetAtPath 1 Answer
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
How to use SerializableDictionary in custom inspector? 0 Answers