Tricks of Serialization in Unity/C#
来源:互联网 发布:als矩阵分析 编辑:程序博客网 时间:2024/05/17 08:34
Tricks of Serialization in Unity/C#
Don’t use XmlSerializer
- XmlSerializer + StringWriter is sloooooow
- XmlSerializer does NOT require [Serializable]
- XmlSerializer does NOT support ISerializable
Use BinaryFormatter + MemoryStream
. It’s fast and customizable.
Use System.Diagnostics.Stopwatch
for simple profile.
Use Encoding.ASCII.GetString()
to convert MemorySteam
to string
Use Convert.ToBase64String
for binary data that contains ‘\0’
IFormatter formatter = new BinaryFormatter();MemoryStream stream = new MemoryStream();formatter.Serialize(stream, target);string result = Convert.ToBase64String(stream.ToArray());//string result = Encoding.ASCII.GetString(stream.ToArray());
Another “trick” for BinaryFormatter in Unity/iOS :
http://answers.unity3d.com/questions/30930/why-did-my-binaryserialzer-stop-working.html
// Just add the following line to the Awake() function of the MonoBehaviour// script and the BinaryFormatter should work fine on iOS. // Forces a different code path in the BinaryFormatter that doesn't rely on // run-time code generation (which would break on iOS).Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes")
0 0
- Tricks of Serialization in Unity/C#
- Serialization in C#
- Object Serialization in C#
- Unity Serialization
- Quick JSON Serialization/Deserialization in C#
- 46 Tips & Tricks for 2D mobile Performance in Unity
- Unity Interface Serialization-Expose Interface field In Inspector
- Serialization from an Object to XML Document in C#
- Unity3D:Unity Serialization
- Learn C# scripting in Unity
- Tricks of R
- tricks in dnn
- Unity iPhone Game Development tricks
- unity 5.3 的 JSON Serialization
- unity 5.3 的 JSON Serialization
- Smooth Rotation of Object in UNITY
- XML Serialization Using C#
- Object Serialization using C#
- mysql
- java 中 equals() 相等的两个对象,hashcode() 一定相等
- [LeetCode] 019. Remove Nth Node From End of List (Easy) (C++/Python)
- OpenCV Using Python——构造方向可控金字塔
- 《完美部署》————centos6.x ,7 上安装opencv3.0.0 python2.7.9【补充+mac安装OpenCV】
- Tricks of Serialization in Unity/C#
- 仿QQ底部弹出效果
- Javascript之事件
- hdu 1045 Fire Net(DFS)
- [Android开发学习] day02
- java中的synchronized
- linux epoll
- web workers及web存储
- Android手动回收bitmap,引发Canvas: trying to use a recycled bitmap处理