In actual development encountered a problem, loading a prefab,unity will report the following error:
A script behaviour has a different serialization layout when loading. (Read bytes but expected bytes), Did you #ifdef unity_editor a section of your serialized properties into any of your Scripts?
Here's the code:
Using Unityengine;
public class Objectpreview:monobehaviour
{
#if unity_editor public
gameobject obj;
void Start ()
{
//code ...
}
#endif
}
In other words, Objectpreview in editor mode and non-editor mode, the serialized content is different
So, because art (or other team members) do prefab in an editor environment, it's serialized data with obj.
At runtime, however, this unity_editor macro causes the runtime to be different from the editor serialization.
The right thing to do is to remove the #if unity_editor or wrap the #if unity_editor the entire class.