您的位置:首页 > 移动开发 > Unity3D

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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: