Unity Serialization
2013-12-16 11:52
190 查看
http://blogs.unity3d.com/2012/10/25/unity-serialization/
一些要点:
What happens when an assembly is reloaded?
When you enter / exit play mode or change a script Unity has to reload the mono assemblies, that is the dll’s associated with Unity.
On the user side this is a 3 step process:
Pull all the serializable data out of managed land, creating an internal representation of the data on the C++ side of Unity.
Destroy all memory / information associated with the managed side of Unity, and reload the assemblies.
Reserialize the data that was saved in C++ back into managed land.
Some Serialization Rules
Avoid structs
Classes you want to be serializable need to be marked with [Serializable]
Public fields are serialized (so long as they reference a [Serializable] class)
Private fields are serialized under some circumstances (editor).
Mark private fields as [SerializeField] if you wish them to be serialized.
[NonSerialized] exists for fields that you do not want to serialize.
一些要点:
What happens when an assembly is reloaded?
When you enter / exit play mode or change a script Unity has to reload the mono assemblies, that is the dll’s associated with Unity.
On the user side this is a 3 step process:
Pull all the serializable data out of managed land, creating an internal representation of the data on the C++ side of Unity.
Destroy all memory / information associated with the managed side of Unity, and reload the assemblies.
Reserialize the data that was saved in C++ back into managed land.
Some Serialization Rules
Avoid structs
Classes you want to be serializable need to be marked with [Serializable]
Public fields are serialized (so long as they reference a [Serializable] class)
Private fields are serialized under some circumstances (editor).
Mark private fields as [SerializeField] if you wish them to be serialized.
[NonSerialized] exists for fields that you do not want to serialize.
相关文章推荐
- Unity Interface Serialization-Expose Interface field In Inspector
- 序列化 (Serialization)的几段定义及在Unity中的使用
- Unity Serialization
- Unity学习笔记 - Assets, Objects and Serialization
- 序列化 (Serialization)的几段定义及在Unity中的使用
- Unity Interface Serialization-Expose Interface field In Inspector
- Unity 网络通信(一)Unity Network 初步
- 【Unity】uLua热更新解决方案
- Unity简单的实现动画三连击脚本
- unity3d shader学习(2)-unity shader的结构
- Unity 最新热更新解决方案 xkLua
- unity中Mathf类的说明
- Unity色子的投掷与点数的获得(详解)
- unity 不同版本安装
- [Unity基础]unity脚本的生命周期
- Unity手游:自动寻路Navmesh入门
- Android获取到手机信号强度信息后传回给unity
- Unity给力插件之ShaderForge(二)
- unity DropDown控件的使用
- Unity抗锯齿